heed icon indicating copy to clipboard operation
heed copied to clipboard

Expose a safe low-level cursor API.

Open nolanderc opened this issue 1 year ago • 3 comments
trafficstars

The LMDB cursor API is quite powerful; something similar should be exposed by heed. The RwIter API gets close, but is unsafe and does not handle seeking to arbitrary keys. The API should allow the following operations:

  • Seeking to an arbitrary key.
  • Seeking to the next/previous key-value pair.
  • Reading the current key/value (could be part of the seeking operations).
  • Inserting an arbitrary key-value pair (LMDB optimizes for cases where the key would end up close to where the cursor is currently pointing).

A full cursor API would also let us efficiently implement an API similar to HashMap::entry (see this comment).

nolanderc avatar Apr 29 '24 18:04 nolanderc

ooh, if that makes multiget possible I'm really looking forward to it!

MathGeniusJodie avatar Aug 04 '24 08:08 MathGeniusJodie

Hey @MathGeniusJodie, @oXtxNt9U, @sebastijankuzner, and @Nuhvi 👋

It's an open-source repository. Feel free to propose solutions though play.rust-lang.org (before implementation) and probably directly expose the internal Cursor type and make it more safe or wrap it if necessary.

Have a nice day 🌞

Kerollmops avatar Aug 13 '24 10:08 Kerollmops

Hey @MathGeniusJodie 👋

The multiget you are talking about is already available in heed 0.21 by using the RoIter::move_through_duplicate_values method for example. I understand that it's maybe not perfect but you might want to test it.

I added this issue, to expose the raw RoCursor/RwCursor publicly as it may be more what people expect from this library.

Kerollmops avatar Mar 06 '25 10:03 Kerollmops