dbTalk Databases Forums  

iterating in reverse

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


Discuss iterating in reverse in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
leon
 
Posts: n/a

Default iterating in reverse - 10-27-2005 , 01:02 PM






Hello,
I'm trying to make a cursor that iterates on records with duplicate
keys, but in reverse order.
I've noticed there's DB_NEXT_DUP, but there's no DB_PREV_DUP flag for
Dbc->get method.
Is there a solution ?
Also, there's no flag for join cursor to iterate backwards.
Any ideas ?

Thanks a lot,

Leon


Reply With Quote
  #2  
Old   
Michael Cahill
 
Posts: n/a

Default Re: iterating in reverse - 10-27-2005 , 08:00 PM






Hi Leon,

At present, the only way to achieve this is to use DB_PREV and check
whether the key has changed.

There is code to do this in the Java API in
java/src/com/sleepycat/db/Cursor.java, in the getPrevDup method. It's
probably more complicated than you need because it makes sure that the
cursor doesn't move on error.

There is no way to go backwards with a join cursor.

If you always want to iterate backwards, you could specify a duplicate
comparison function that orders the duplicates the way you want.

Regards,
Michael.


Reply With Quote
  #3  
Old   
leon
 
Posts: n/a

Default Re: iterating in reverse - 10-28-2005 , 01:17 AM



Thank you Michael, I'll check this out

Leon


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.