Iterating over range -
12-13-2005
, 09:05 PM
As I have not much experience yet writing Berkeley DB apps,
maybe this question is naive:
I am trying to iterate over a range of records given a start and an
end key. Now, it is easy to set the cursor to the start position
using DB_SET_RANGE.
However, I would like to determine the end of the iteration without
calling the BTree comparison function for each retrieved key.
One way that might work - IMO - is this:
- Use a BTree database enabled for record numbers.
- Set the cursor to the end position and retrieve the record number.
- Set the cursor to the start position and begin to iterate.
- For each retrieved record, get the record number and compare to the
end position's record number to determine the last record.
Does that make sense?
What if the last record gets replaced concurrently
(not matching anymore)?
Can that be prevented using transactions?
Karl |