|
|
@ -296,17 +296,17 @@ fn iterator_test() { |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
let iter = db.iterator(IteratorMode::Start); |
|
|
|
let iter = db.iterator(IteratorMode::Start); |
|
|
|
assert_eq!(iter.collect::<Vec<_>>(), expected); |
|
|
|
assert_eq!(iter.map(Result::unwrap).collect::<Vec<_>>(), expected); |
|
|
|
|
|
|
|
|
|
|
|
// Test that it's idempotent
|
|
|
|
// Test that it's idempotent
|
|
|
|
let iter = db.iterator(IteratorMode::Start); |
|
|
|
let iter = db.iterator(IteratorMode::Start); |
|
|
|
assert_eq!(iter.collect::<Vec<_>>(), expected); |
|
|
|
assert_eq!(iter.map(Result::unwrap).collect::<Vec<_>>(), expected); |
|
|
|
let iter = db.iterator(IteratorMode::Start); |
|
|
|
let iter = db.iterator(IteratorMode::Start); |
|
|
|
assert_eq!(iter.collect::<Vec<_>>(), expected); |
|
|
|
assert_eq!(iter.map(Result::unwrap).collect::<Vec<_>>(), expected); |
|
|
|
|
|
|
|
|
|
|
|
// Test in reverse
|
|
|
|
// Test in reverse
|
|
|
|
let iter = db.iterator(IteratorMode::End); |
|
|
|
let iter = db.iterator(IteratorMode::End); |
|
|
|
let mut tmp_vec = iter.collect::<Vec<_>>(); |
|
|
|
let mut tmp_vec = iter.map(Result::unwrap).collect::<Vec<_>>(); |
|
|
|
tmp_vec.reverse(); |
|
|
|
tmp_vec.reverse(); |
|
|
|
|
|
|
|
|
|
|
|
let old_iter = db.iterator(IteratorMode::Start); |
|
|
|
let old_iter = db.iterator(IteratorMode::Start); |
|
|
@ -317,13 +317,16 @@ fn iterator_test() { |
|
|
|
(k3.clone(), v3.clone()), |
|
|
|
(k3.clone(), v3.clone()), |
|
|
|
(k4.clone(), v4.clone()), |
|
|
|
(k4.clone(), v4.clone()), |
|
|
|
]; |
|
|
|
]; |
|
|
|
assert_eq!(old_iter.collect::<Vec<_>>(), expected); |
|
|
|
assert_eq!(old_iter.map(Result::unwrap).collect::<Vec<_>>(), expected); |
|
|
|
|
|
|
|
|
|
|
|
let iter = db.iterator(IteratorMode::Start); |
|
|
|
let iter = db.iterator(IteratorMode::Start); |
|
|
|
assert_eq!(iter.collect::<Vec<_>>(), expected2); |
|
|
|
assert_eq!(iter.map(Result::unwrap).collect::<Vec<_>>(), expected2); |
|
|
|
|
|
|
|
|
|
|
|
let iter = db.iterator(IteratorMode::From(b"k3", Direction::Forward)); |
|
|
|
let iter = db.iterator(IteratorMode::From(b"k3", Direction::Forward)); |
|
|
|
assert_eq!(iter.collect::<Vec<_>>(), vec![(k3, v3), (k4, v4)]); |
|
|
|
assert_eq!( |
|
|
|
|
|
|
|
iter.map(Result::unwrap).collect::<Vec<_>>(), |
|
|
|
|
|
|
|
vec![(k3, v3), (k4, v4)] |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -372,7 +375,7 @@ fn prefix_extract_and_iterate_test() { |
|
|
|
.into_iter() |
|
|
|
.into_iter() |
|
|
|
.map(|(k, v)| (k.to_vec().into_boxed_slice(), v.to_vec().into_boxed_slice())) |
|
|
|
.map(|(k, v)| (k.to_vec().into_boxed_slice(), v.to_vec().into_boxed_slice())) |
|
|
|
.collect(); |
|
|
|
.collect(); |
|
|
|
assert_eq!(expected, iter.collect::<Vec<_>>()); |
|
|
|
assert_eq!(expected, iter.map(Result::unwrap).collect::<Vec<_>>()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -469,17 +472,17 @@ fn transaction_iterator() { |
|
|
|
let txn = db.transaction(); |
|
|
|
let txn = db.transaction(); |
|
|
|
|
|
|
|
|
|
|
|
let iter = txn.iterator(IteratorMode::Start); |
|
|
|
let iter = txn.iterator(IteratorMode::Start); |
|
|
|
assert_eq!(iter.collect::<Vec<_>>(), expected); |
|
|
|
assert_eq!(iter.map(Result::unwrap).collect::<Vec<_>>(), expected); |
|
|
|
|
|
|
|
|
|
|
|
// Test that it's idempotent
|
|
|
|
// Test that it's idempotent
|
|
|
|
let iter = txn.iterator(IteratorMode::Start); |
|
|
|
let iter = txn.iterator(IteratorMode::Start); |
|
|
|
assert_eq!(iter.collect::<Vec<_>>(), expected); |
|
|
|
assert_eq!(iter.map(Result::unwrap).collect::<Vec<_>>(), expected); |
|
|
|
let iter = txn.iterator(IteratorMode::Start); |
|
|
|
let iter = txn.iterator(IteratorMode::Start); |
|
|
|
assert_eq!(iter.collect::<Vec<_>>(), expected); |
|
|
|
assert_eq!(iter.map(Result::unwrap).collect::<Vec<_>>(), expected); |
|
|
|
|
|
|
|
|
|
|
|
// Test in reverse
|
|
|
|
// Test in reverse
|
|
|
|
let iter = txn.iterator(IteratorMode::End); |
|
|
|
let iter = txn.iterator(IteratorMode::End); |
|
|
|
let mut tmp_vec = iter.collect::<Vec<_>>(); |
|
|
|
let mut tmp_vec = iter.map(Result::unwrap).collect::<Vec<_>>(); |
|
|
|
tmp_vec.reverse(); |
|
|
|
tmp_vec.reverse(); |
|
|
|
|
|
|
|
|
|
|
|
let old_iter = txn.iterator(IteratorMode::Start); |
|
|
|
let old_iter = txn.iterator(IteratorMode::Start); |
|
|
@ -490,13 +493,16 @@ fn transaction_iterator() { |
|
|
|
(k3.clone(), v3.clone()), |
|
|
|
(k3.clone(), v3.clone()), |
|
|
|
(k4.clone(), v4.clone()), |
|
|
|
(k4.clone(), v4.clone()), |
|
|
|
]; |
|
|
|
]; |
|
|
|
assert_eq!(old_iter.collect::<Vec<_>>(), expected); |
|
|
|
assert_eq!(old_iter.map(Result::unwrap).collect::<Vec<_>>(), expected); |
|
|
|
|
|
|
|
|
|
|
|
let iter = txn.iterator(IteratorMode::Start); |
|
|
|
let iter = txn.iterator(IteratorMode::Start); |
|
|
|
assert_eq!(iter.collect::<Vec<_>>(), expected2); |
|
|
|
assert_eq!(iter.map(Result::unwrap).collect::<Vec<_>>(), expected2); |
|
|
|
|
|
|
|
|
|
|
|
let iter = txn.iterator(IteratorMode::From(b"k3", Direction::Forward)); |
|
|
|
let iter = txn.iterator(IteratorMode::From(b"k3", Direction::Forward)); |
|
|
|
assert_eq!(iter.collect::<Vec<_>>(), vec![(k3, v3), (k4, v4)]); |
|
|
|
assert_eq!( |
|
|
|
|
|
|
|
iter.map(Result::unwrap).collect::<Vec<_>>(), |
|
|
|
|
|
|
|
vec![(k3, v3), (k4, v4)] |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|