|
|
|
@ -20,7 +20,7 @@ use pretty_assertions::assert_eq; |
|
|
|
|
|
|
|
|
|
use rocksdb::{ |
|
|
|
|
perf::get_memory_usage_stats, BlockBasedOptions, BottommostLevelCompaction, Cache, |
|
|
|
|
CompactOptions, CuckooTableOptions, DBCompactionStyle, DBWithThreadMode, Env, Error, |
|
|
|
|
CompactOptions, CuckooTableOptions, DBAccess, DBCompactionStyle, DBWithThreadMode, Env, Error, |
|
|
|
|
FifoCompactOptions, IteratorMode, MultiThreaded, Options, PerfContext, PerfMetric, ReadOptions, |
|
|
|
|
SingleThreaded, SliceTransform, Snapshot, UniversalCompactOptions, |
|
|
|
|
UniversalCompactionStopStyle, WriteBatch, DB, |
|
|
|
@ -926,20 +926,59 @@ fn multi_get() { |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
let db = DB::open_default(&path).unwrap(); |
|
|
|
|
let initial_snap = db.snapshot(); |
|
|
|
|
db.put(b"k1", b"v1").unwrap(); |
|
|
|
|
let k1_snap = db.snapshot(); |
|
|
|
|
db.put(b"k2", b"v2").unwrap(); |
|
|
|
|
|
|
|
|
|
let _ = db.multi_get(&[b"k0"; 40]); |
|
|
|
|
|
|
|
|
|
let assert_values = |values: Vec<_>| { |
|
|
|
|
assert_eq!(3, values.len()); |
|
|
|
|
assert_eq!(values[0], None); |
|
|
|
|
assert_eq!(values[1], Some(b"v1".to_vec())); |
|
|
|
|
assert_eq!(values[2], Some(b"v2".to_vec())); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
let values = db |
|
|
|
|
.multi_get(&[b"k0", b"k1", b"k2"]) |
|
|
|
|
.into_iter() |
|
|
|
|
.map(Result::unwrap) |
|
|
|
|
.collect::<Vec<_>>(); |
|
|
|
|
assert_eq!(3, values.len()); |
|
|
|
|
assert_eq!(values[0], None); |
|
|
|
|
assert_eq!(values[1], Some(b"v1".to_vec())); |
|
|
|
|
assert_eq!(values[2], Some(b"v2".to_vec())); |
|
|
|
|
|
|
|
|
|
assert_values(values); |
|
|
|
|
|
|
|
|
|
let values = DBAccess::multi_get_opt(&db, &[b"k0", b"k1", b"k2"], &Default::default()) |
|
|
|
|
.into_iter() |
|
|
|
|
.map(Result::unwrap) |
|
|
|
|
.collect::<Vec<_>>(); |
|
|
|
|
|
|
|
|
|
assert_values(values); |
|
|
|
|
|
|
|
|
|
let values = db |
|
|
|
|
.snapshot() |
|
|
|
|
.multi_get(&[b"k0", b"k1", b"k2"]) |
|
|
|
|
.into_iter() |
|
|
|
|
.map(Result::unwrap) |
|
|
|
|
.collect::<Vec<_>>(); |
|
|
|
|
|
|
|
|
|
assert_values(values); |
|
|
|
|
|
|
|
|
|
let none_values = initial_snap |
|
|
|
|
.multi_get(&[b"k0", b"k1", b"k2"]) |
|
|
|
|
.into_iter() |
|
|
|
|
.map(Result::unwrap) |
|
|
|
|
.collect::<Vec<_>>(); |
|
|
|
|
|
|
|
|
|
assert_eq!(none_values, vec![None; 3]); |
|
|
|
|
|
|
|
|
|
let k1_only = k1_snap |
|
|
|
|
.multi_get(&[b"k0", b"k1", b"k2"]) |
|
|
|
|
.into_iter() |
|
|
|
|
.map(Result::unwrap) |
|
|
|
|
.collect::<Vec<_>>(); |
|
|
|
|
|
|
|
|
|
assert_eq!(k1_only, vec![None, Some(b"v1".to_vec()), None]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|