Emmanuel Lécharny wrote:
Hi,

some thoughts about the current implementation :

Cursor support in Mavibot
-------------------------

The current implementation is a bit unsastifactory, and it does not
necessarily fits with the simplifications we are introducing (namely,
the removal of duplicate values). Typically, the current cursor allows
the user to move forward and backward across keys and values, when we
only need to move across keys now.

Moving
------

First of all, we must be able to move backward and forward. Fetching an
element is a different operation than moving, but one should still be
able to get back an element when moving. This is done through 4 methods,
2 which are relative, and 2 which are absolute.

Relative moves :
next() : move forward to the net key
prev() : move forward to the net key

Absolute moves :
next(K) : move after the given key
prev(K) : move before the given key

These absolute moves seem like an extravagance. I have never seen a dbm-style library with such methods. It's more natural to have an explicit seek() method and then do a relative next/prev after that.

For reference, in BerkeleyDB, there is cursor_first/last. Also, on a freshly created cursor, next() == first() and prev() == last(). That is, the first/last methods aren't even needed on a fresh cursor.

--
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/

Reply via email to