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

Maybe add DB.get_or_next() and DB.get_or_prev() API #23

Open
wbolster opened this issue Nov 3, 2013 · 2 comments
Open

Maybe add DB.get_or_next() and DB.get_or_prev() API #23

wbolster opened this issue Nov 3, 2013 · 2 comments

Comments

@wbolster
Copy link
Owner

wbolster commented Nov 3, 2013

To avoid messing with iterators, the DB could have .get_or_next(...) and .get_or_prev(...) methods. In addition to the args already supported by the .get() method, it would also have include_key and include_value args.

Support for snapshots and prefixed databases sounds doable as well.

@wbolster
Copy link
Owner Author

Fwiw, the currently working alternative is something like next(db.iter(...), 'default-value').

@tlevine
Copy link

tlevine commented Mar 16, 2016

I have implemented this.

The following changes since commit 857ec9d:

Merge pull request #40 from felixonmars/master (2015-10-28 15:55:37 +0100)

are available in the git repository at:

git@github.com:tlevine/plyvel get-or

for you to fetch changes up to cc4327a:

fix get_or documentation (2016-03-16 16:21:38 +0000)


Thomas Levine (9):
example of get_or_{prev,next}
add include_key, include_value
test case for get_or
implement get_or
document get_or_next, get_or_prev
typos in test
handle None properly in test
remove partials
fix get_or documentation

doc/api.rst | 26 ++++++++++++++++++++++++++
get_or_example.py | 42 ++++++++++++++++++++++++++++++++++++++++++
plyvel/_plyvel.pyx | 23 +++++++++++++++++++++++
test/test_plyvel.py | 22 ++++++++++++++++++++++
4 files changed, 113 insertions(+)
create mode 100644 get_or_example.py

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

2 participants