dbTalk Databases Forums  

howto get the max value of KEY?

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


Discuss howto get the max value of KEY? in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
wanghui00@gmail.com
 
Posts: n/a

Default howto get the max value of KEY? - 03-07-2006 , 01:12 AM






I use BTREE, and the key type is int, so is there a way to get the max
value easily? the question is I don't know the range, I just want to
know the range. thanks~


Reply With Quote
  #2  
Old   
Patrick Schaaf
 
Posts: n/a

Default Re: howto get the max value of KEY? - 03-07-2006 , 01:54 AM






wanghui00 (AT) gmail (DOT) com writes:

Quote:
I use BTREE, and the key type is int, so is there a way to get the max
value easily? the question is I don't know the range, I just want to
know the range.
Assuming your BTREE really sorts your ints the way you expect,
use a cursor->c_get with flag DB_LAST.

best regards
Patrick


Reply With Quote
  #3  
Old   
wanghui00@gmail.com
 
Posts: n/a

Default Re: howto get the max value of KEY? - 03-07-2006 , 09:48 PM



thanks!
it works! but strangely, DB_LAST doesnot return the max one (near to
MAX), I didn't put records with DB_APPEND, why? need I sort the db
first?
anyway, if I try to get a larger value starting from it (the one got
from DB_LAST), I get the max value last.


Reply With Quote
  #4  
Old   
michael.cahill@gmail.com
 
Posts: n/a

Default Re: howto get the max value of KEY? - 03-08-2006 , 12:05 AM



Quote:
strangely, DB_LAST doesnot return the max one (near to MAX),
The most likely cause is that you are using ints as keys on a little
endian machine. See this FAQ entry for more information:

http://dev.sleepycat.com/resources/faq_show.html?id=70

Regards,
Michael.



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.