qddb_search
command returns a keylist
descriptor. This keylist descriptor can then be (1) used to produce
rows matching the query, (2) combined with other keylists using
intersection, union, and exclusion, (3) pruned of duplicate rows or
entries, (4) copied and sorted, and (5) used to directly read tuples.
set s [qddb_schema open MyRelation] set k [qddb_search $s -prunebyattr A word_range r - z] set k [qddb_keylist process nullop -deldup_sameentry on] $k foreach i [qddb_keylist get $k] { set t [qddb_tuple read $s $i] if {[string length $t] == 0} {continue} puts [qddb_tuple get readable $t] qddb_tuple delete $t } qddb_keylist delete $k qddb_schema close $s
First, we
open the schema and search for a word range ``r-z'' within attribute
``A''; the qddb_search
command returns a keylist that we use to
find the matching tuples. We may have multiple keylist nodes for any
individual matching tuple, so now we must prune the keylist of all nodes
referring to the same entry. Finally, we walk through the keylist and
(1) read the tuple, (2) check to see if the tuple we read is valid (not
deleted), (3) print the tuple in readable form, and (4) delete the tuple
from memory. Notice that we did not lock the tuple before we read it.
This is because Qddb takes care of read locks for you. A qddb_tuple
read
(or any other Qddb command that reads a tuple) will
wait for any writes to complete before reading. Read and write
operations are atomic in Qddb, so even if the tuple is locked for
writing, you will still be able to read it. You only need to invoke
qddb_tuple
lock
before writing a tuple.