Skip to content

Instantly share code, notes, and snippets.

@aglyzov
Last active December 17, 2015 17:09
Show Gist options
  • Save aglyzov/5643563 to your computer and use it in GitHub Desktop.
Save aglyzov/5643563 to your computer and use it in GitHub Desktop.
A bug in plyvel 0.2 -- reverse iterators with prefix are badly broken
#!/bin/env python3
import plyvel
db = plyvel.DB('/tmp/test-reverse-iterator.db', create_if_missing=True)
db.put(b'aaa', b'1')
db.put(b'bbb', b'2')
# these pass:
assert list(db.iterator(reverse=True)) == [(b'bbb', b'2'), (b'aaa', b'1')]
assert list(db.iterator(prefix=b'b')) == [(b'bbb', b'2')]
assert list(db.iterator(prefix=b'c')) == []
assert list(db.prefixed_db(b'c').iterator()) == []
# these fail:
assert list(db.iterator(prefix=b'c', reverse=True)) == []
assert list(db.prefixed_db(b'c').iterator(reverse=True)) == []
@wbolster
Copy link

wbolster commented Jun 3, 2013

See wbolster/plyvel#9 for the accompanying bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment