Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Genuine iterators, reverse iterators #213

Open
martinsumner opened this issue Nov 28, 2018 · 0 comments
Open

Genuine iterators, reverse iterators #213

martinsumner opened this issue Nov 28, 2018 · 0 comments

Comments

@martinsumner
Copy link
Owner

martinsumner commented Nov 28, 2018

Many KV stores offer an iterator feature which allows calls to next or prev to move forward and back across the store.

Leveled as a backend had a requirement to support folds over ranges of keys (or keys and metadata). To implement such folds, it can take a snapshot copy of a penciller. The penciller has keys and metadata in memory (level -1) and keys and metadata in sst files (level 0 +), and the snapshot will be a process containing only the in-memory keys/metadata in the required range, and pointers to the SST files at each level that cover the range. When the fold is started, the sst files are asked to expand out the range into lists of actual keys (up to a maximum size), and the penciller then scans up and down the levels trying to determine what the next key is and when the next key is determined the fold function is applied, and continues to be applied to the next key until either the end of the range is reached or an exception is thrown by the fold function to exit out.

There is sort of a next function possible, in that you could have a range with only a start key, and state the maximum number of keys the fold function wishes to apply to 1 - and therefore the function can return just the next key after the start key. However, this is more expensive than finding a single key, and the full cost would need to be faced again to find the next key after that.

So is there a better way of doing next and prev, and also virtually first and last?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant