You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Emmanuel Lécharny <el...@gmail.com> on 2013/11/15 12:21:25 UTC

[Mavibot] cursor API

Hi guys,

currently, we have a cursor API which is used to brows a BTree. It's
pretty much mapped on what we have in ApacheDS. Now, there are a few
thing that can be improved :

1) first, the cursor is a *value* cursor. As we support multiple values
for a given key, that means we will return Tuple<K, V> where the key
will be the same. That's ok, but we also need a way to browse keys.

What we have is a way to create a new cursor starting at a specific key
: Btree.browseFrom(K). It returns a new cursor, in which you can fetch
the next key by doing a mobeToNextNoDuplicateKey() (or moveToPrev...)


We would like to do that on an existing cursor, instead of creating a
new cursor. We also would like to have a consistent way to access data.
In the current API, if you want to get the key which is after a given
key, here is what you need to do :

Cursor cursor = btree.browseFrom( K1 );
cursor.moveToNextNonDuplicateKey();
Tuple tuple = cursor.next();

This is quite overkilling. A probably better idea would be to add two
methods in the BTree and Cursor interfaces :

BTree.browseAfter( K ) : position the cursor after a given key
cusor.nextKey()/prevKey() : move to the next/prev key. We will always
point to teh first value of the found key.

That would make it easier for implementers to use te cursor lib...

Thoughs ?

-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com