dbTalk Databases Forums  

Iterating over range

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss Iterating over range in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
karl@waclawek.net
 
Posts: n/a

Default 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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.