plyvel
plyvel copied to clipboard
Maybe add DB.get_or_next() and DB.get_or_prev() API
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.
Fwiw, the currently working alternative is something like next(db.iter(...), 'default-value')
.
I have implemented this.
The following changes since commit 857ec9d09cd2597cb8ce1bd08c1978cf49838f01:
Merge pull request #40 from felixonmars/master (2015-10-28 15:55:37 +0100)
are available in the git repository at:
[email protected]:tlevine/plyvel get-or
for you to fetch changes up to cc4327a7d758619756b88a7a212ffa084e9bcd9c:
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