Open wbolster opened 10 years ago
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:
git@github.com: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 getor{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
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 haveinclude_key
andinclude_value
args.Support for snapshots and prefixed databases sounds doable as well.