c***@gmail.com
2007-01-25 20:49:14 UTC
Hi!
I use a BTree as an indexing structure for my berkeleydb database. The
keys are all 4 bytes long, unsigned integers. And i use cursors to
traverse the database in both directions.
I thought that since i use a Btree, the elements are sorted, and the
cursors traverse a sorted tree. I thought that if i position the cursor
at the first element, i get the smallest key, and the last element is
the largest key. But i noticed that this is not the case - the cursors
rather return the elements in the order of insertion (the oldest
element is in DB_FIRST, the youngest in DB_LAST).
Is there a way how i can get "real" sorting?
Why does bdb use this sorting "by age"? Is there a special reason why
they decided to do so?
Regards & big thanks
Chris
I use a BTree as an indexing structure for my berkeleydb database. The
keys are all 4 bytes long, unsigned integers. And i use cursors to
traverse the database in both directions.
I thought that since i use a Btree, the elements are sorted, and the
cursors traverse a sorted tree. I thought that if i position the cursor
at the first element, i get the smallest key, and the last element is
the largest key. But i noticed that this is not the case - the cursors
rather return the elements in the order of insertion (the oldest
element is in DB_FIRST, the youngest in DB_LAST).
Is there a way how i can get "real" sorting?
Why does bdb use this sorting "by age"? Is there a special reason why
they decided to do so?
Regards & big thanks
Chris