You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first key it yields is the a key that's not in the [stop_key, start_key] range, but is actually the first one after start_key.
Example: if my db has keys ["a", "c", "e", "g"] and start_key is "d", stop_key is "a".
Then the first key yielded is "e", which is outside of the "d"->"a" range I am asking.
The text was updated successfully, but these errors were encountered:
This is probably a bug that slipped review. The leveldb iterator protocol is annoying in the way that the first step of iteration is a little different from the following.
Ok, so actually this happens only if the from() key is not present in the DB: then the first key given will be out of range. Otherwise it's fine.
This tests both this bug and that it ends before the to() passed.
When fixing it would be nice to test with .from(&9) as well, in my workaround this needed to be handled differently.
#[test]
fn test_key_iterator_iterate_reverse_from_to() {
let tmp = tmpdir("key_iter");
let database = &mut open_database(tmp.path(), true);
db_put_simple(database, 2, &[2]);
db_put_simple(database, 4, &[4]);
db_put_simple(database, 6, &[6]);
db_put_simple(database, 8, &[8]);
let iterable: &mut Iterable<i32> = database;
let read_opts = ReadOptions::new();
let mut iter = iterable.keys_iter(read_opts).reverse().from(&7).to(&3);
let vec: Vec<i32> = iter.collect();
assert_eq!(vec, vec![6, 4]);
}
If I instantiate a reverse iterator like so:
The first key it yields is the a key that's not in the [stop_key, start_key] range, but is actually the first one after start_key.
Example: if my db has keys ["a", "c", "e", "g"] and start_key is "d", stop_key is "a".
Then the first key yielded is "e", which is outside of the "d"->"a" range I am asking.
The text was updated successfully, but these errors were encountered: