database-stream-processor icon indicating copy to clipboard operation
database-stream-processor copied to clipboard

`Cursor::seek` should return the number of keys skipped over during search

Open ryzhyk opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe.

This will help us preallocate the right amount of buffer space in some situations, see e.g., the TODO in window.rs.

Describe the solution you'd like

Describe alternatives you've considered

No response

Additional context

No response

ryzhyk avatar Jun 23 '22 15:06 ryzhyk

FYI We won't be able to get that from the rocksdb cursor

gz avatar Oct 11 '22 06:10 gz

We could make our cursor interface overly general (either by adding extra functions or making it a composition of multiple "bare" cursor traits and extension traits) and then allow consumers to query the current cursor for its capabilities. Since we construct circuits once before running them, this could allow something along these lines:

if CursorType::seek_returns_skipped_keys() {
    circuit.add_operator(something_that_uses_skipped_keys());
} else {
    circuit.add_operator(some_fallback_implementation());
}

Kixiron avatar Oct 11 '22 16:10 Kixiron

While I'm thinking about it though, seek could probably return a bool that corresponds to Cursor::key_valid() (that is, it returns false if we sought (seeked? sook?) past all valid keys)

Kixiron avatar Oct 11 '22 16:10 Kixiron