Content-type: text/html; charset=UTF-8
qddb_rows all ?-format rows? ?-instance attr,inst? ?-rowdescs on|off? \ ?<options>? <tuple_desc> Return value: { <row_desc> "row values" } { <row_desc> "row values" } ... qddb_rows all ?-format table? ?-instance attr,inst? ?-rowdescs on|off? \ ?<options>? <tuple_desc> Return value: a <table desc> qddb_rows select ?-format rows? ?<options>? <keylist_desc> (default) ->Return value: { <tuple_desc> <row_desc> "row value" } { <tuple_desc> <row_desc> "row value" } ... qddb_rows select -format query ?<options>? <keylist_desc> ->Return value: { { row value } { Start Length Number Type } { attr,inst ... } } { { row value } { Start Length Number Type } { attr,inst ... } } ... qddb_rows select -format table ?<options>? <keylist_desc> ->Return value: a <table desc> qddb_rows get <row_desc> qddb_rows getval <attribute list> <row_desc> qddb_rows sort ?-ascending <attribute list>? <attribute list> <row_desc list> qddb_rows tuplename <row_desc> qddb_rows delete <row desc>|all <options>: -attrs <attribute list> - unordered list of significant attributes ('qddb_rows select' only, obsolete) -print <print list> - ordered list of attributes to print (format: { attr[:width] attr[:width] ... }) -sortby <attr list> - ordered list of attributes selected from the '-print' option's list -ascending <attr list> - unordered subset of list supplied by '-sortby' to be sorted in ascending order -sep string - use the supplied string as a column separator -norows on|off - suppress printing of attr,inst pairs when using '-format query' (default: off) -suppress on|off - suppress printing of row values (default: off) -tclelements on|off - return row values as Tcl elements (default: off) -flush on|off - flush each tuple from memory after producing rows to save memory (default: off) -deldup_rows on|off - delete duplicate rows from those produced by the same tuple (default: off)
{ Name.First Name.Last Address.Street Address.City }
specifies that we want only rows that matched in those attributes. An example command sequence might be:
set s [qddb_schema open Family] set k0 [qddb_search $s George] set k1 [qddb_search $s Harris] set k2 [qddb_search $s Rosemont] set k3 [qddb_search $s Richmond] set k0 [qddb_keylist process prune -prunebyattr Name.First $k0] set k1 [qddb_keylist process prune -prunebyattr Name.Last $k1] set k2 [qddb_keylist process prune -prunebyattr Address.Street $k2] set k3 [qddb_keylist process prune -prunebyattr Address.City $k3] foreach i [list $k1 $k2 $k3] { set k0 [qddb_keylist op intersection $k0 $i] } set r [qddb_rows select -format rows -deldup_rows on \ -attrs {Name.First Name.Last Address.Street Address.city} \ -print {Name.First:10 Name.Last:15 Address.Street} $k0] puts $r qddb_schema close $s qddb_keylist delete all qddb_rows delete all qddb_tuple delete allThis sequence (1) searches for the keys, (2) prunes the keylists of any nodes not pertaining to the desired attributes, (3) performs an intersection on the resulting lists, and (4) selects the rows from the keylist, and (5) prints out the result.
<print list> is of the same form as <attribute list>, but with an optional width field:
{ Name.First:10 Name.Last:15 Address.Street:20 Address.City:15 }If the width field is absent, the attribute's value is not truncated and each field's value is a TCL-list element.
The -format query option forces qddb_rows select to throw away the tuples after it finds the row values. If -format rows is in effect, then the tuples are all kept in memory. Obviously, if you have a very large database, and you don't control the number of tuples that a query can match, then you should use the -flush on option (unless you have a huge amount of RAM in your machine).
qddb_rows all -sep " " -instance Person.Address,1.1 -print { Person.Name.First Person.Name.Last Person.Address.Street } $tuple
would operate on the following readable tuple
Person ( Name ( First = "Henry" Last = "McKinney" ) Name ( First = "Georgia" Last = "McKinney" ) Address ( Street = "123 Rowdy Way" ) Address ( Street = "2312 Dougherty Parkway" ) ) Person ( Name ( First = "Monrey" Last = "Montavere" ) Address ( Street = "321 Howdy Way" ) )and produce rows containing:
Henry McKinney 123 Rowdy Way Georgia McKinney 123 Rowdy Way
To produce rows with all instances of the Person.Address attribute, you may specify -instance Person.Address,1. This will produce all rows with the 1st Person and any Address. For example, using the readable tuple above you would get:
Henry McKinney 123 Rowdy Way Henry McKinney 2312 Dougherty Parkway Georgia McKinney 123 Rowdy Way Georgia McKinney 2312 Dougherty Parkway
1) each row is the same as would be returned by qddb_rows all -format rows 2) column names are fully qualified attribute names (in order) from the -print option's list 3) the column titles are the verbosenames of the corresponding attributes 4) each column type defaults to the corresponding attribute type 5) row comment fields are set to "<tuple_desc> <row_desc>" unless '-rowdescs off' is specified
{ <tuple desc> <row desc> {} } { <tuple desc> <row desc> {} }If <print list> is supplied, then the value for each attribute specified in <print list> is returned as the fourth sub-element in each element of the returned list and all duplicate rows are deleted:
{ <tuple desc> <row desc> { <formatted string> } { <tuple desc> <row desc> { <formatted string> }The option -suppress on forces the suppression of the formatted string, but still deletes duplicate rows based on the -print options. The -sortby and -ascending options each accepts a list of leaf attributes. -sortby specifies the sorting order of the rows, while -ascending determines which attributes are sorted in ascending (increasing) order. The default sorting order is descending (decreasing). The option -tclelements on replaces the formatted string with a list of full element values. The <tuple desc> in each row is a ready-to-use tuple descriptor, distinct from any tuple descriptor that was open at the time of the call. Each returned <tuple desc> must be deleted when the application is finished with it (as well as each <row desc>). The option -flush on flushes tuple from memory as it reads them to obtain row values. The flush option is faster when memory is limited and many tuples are returned from a query (it is somewhat slower when memory isn't an issue).
1) each row is the same as would be returned by qddb_rows select -format rows 2) column names are fully qualified attribute names (in order) from the -print option's list 3) the column titles are the verbosenames of the corresponding attributes 4) each column type defaults to the corresponding attribute type 5) row comment fields are set to "<tuple_desc> <row_desc>" if '-rowdescs on' is specified (default is 'off').Since the option '-rowdescs on' provides a tuple and row descriptor in the comment field for each row, the user is responsible for explicitly deleting the tuples and rows after use. For example, the following code will walk through such a table, delete all tuple and row descriptors, then finally delete the table itself.
... set table [qddb_rows select -format table -attrs {A B C} -print {A B C} -rowdescs on $keylist] set maxnum [qddb_table row maxnum $table] for {set i 1} {$i <= $maxnum} {incr i} { set tuple [qddb_table row cget $table $i -comment] catch "qddb_tuple delete [lindex $tuple 0]" } qddb_table delete $table
This command finds all rows in exactly the same manner as qddb_rows select. The return value is a table descriptor suitable as an argument to qddb_table. Each column in the table is named by the corresponding attribute (i.e. A.B.C), has the same type, and the title is the verbosename of the attribute. The -rowdesc on option places a row descriptor in the comment field of each row in the table; if -rowdesc is off, the corresponding tuples and rows are not saved and are deleted from memory as each tuple is read. The -flush on option flushes each tuple from memory, but still saves the row descriptor in the comment field of each row for later use. Note that table operations are generally much faster than manipulating standard Tcl lists. If speed of table operations is important to you, you should use this command instead of qddb_rows select.
% qddb_rows getval { Person.Name.First Person.Name.Last } $r {Eric} {Herrin}Note that any spaces in the attributes' values are not trimmed.
qddb_row1 {Henry} {McKinney} qddb_row2 {George} {Wilbur} qddb_row3 {Zoe} {Appleton} qddb_row4 {George} {Arthur}an example use of qddb_rows sort might be:
% qddb_rows sort -ascending {Person.Name.Last Person.Name.First} \ {Person.Name.First Person.Name.Last} \ {qddb_row1 qddb_row2 qddb_row3 qddb_row4} qddb_row1 qddb_row4 qddb_row2 qddb_row3 % qddb_rows sort -ascending {Person.Name.Last Person.Name.First} \ {Person.Name.Last Person.Name.First} \ {qddb_row1 qddb_row2 qddb_row3 qddb_row4} qddb_row3 qddb_row4 qddb_row1 qddb_row2 % qddb_rows sort {Person.Name.Last Person.Name.First} \ {qddb_row1 qddb_row2 qddb_row3 qddb_row4} qddb_row2 qddb_row1 qddb_row4 qddb_row3The -ascending option's argument is a subset of the <attribute list> specifying which of the columns are to be sorted in an ascending fashion. The default is descending. The qddb_rows getval command may then be used to get the values from the individual rows for viewing purposes. Note that the sorting process uses the natural sorting method for the type of attribute (integer, real, string, or date).
A Guide to QDDB Eric H. Herrin II and Raphael A. Finkel Qddb User's Guide An ASCII Database for Fast Queries of Relatively Stable Data Eric H. Herrin II and Raphael A. Finkel Computing Systems, Volume 4 Number 2 University of California Press, Berkeley CA Schema and Tuple Trees: An Intuitive Structure for Representing Relational Data Eric H. Herrin, II and Raphael A. Finkel Computing Systems, Volume 9, Number 2 MIT Press, Cambridge MA TCL and the TK Toolkit John K. Ousterhout Addison-Wesley, 1994 ISBN 0-201-63337-X