diff --git a/core/src/kvs/rocksdb/mod.rs b/core/src/kvs/rocksdb/mod.rs index f7847f3e..d7bc9a8b 100644 --- a/core/src/kvs/rocksdb/mod.rs +++ b/core/src/kvs/rocksdb/mod.rs @@ -404,23 +404,21 @@ impl super::api::Transaction for Transaction { // Set the ReadOptions with the snapshot let mut ro = ReadOptions::default(); ro.set_snapshot(&inner.snapshot()); + ro.set_async_io(true); + ro.fill_cache(true); // Create the iterator let mut iter = inner.raw_iterator_opt(ro); // Seek to the start key iter.seek(&rng.start); - // Scan the keys in the iterator - while iter.valid() { - // Check the scan limit - if res.len() < limit as usize { - // Get the key and value - let k = iter.key(); - // Check the key and value - if let Some(k) = k { - if k >= beg && k < end { - res.push(k.to_vec()); - iter.next(); - continue; - } + // Check the scan limit + while res.len() < limit as usize { + // Check the key and value + if let Some(k) = iter.key() { + // Check the range validity + if k >= beg && k < end { + res.push(k.to_vec()); + iter.next(); + continue; } } // Exit @@ -455,23 +453,21 @@ impl super::api::Transaction for Transaction { // Set the ReadOptions with the snapshot let mut ro = ReadOptions::default(); ro.set_snapshot(&inner.snapshot()); + ro.set_async_io(true); + ro.fill_cache(true); // Create the iterator let mut iter = inner.raw_iterator_opt(ro); // Seek to the start key iter.seek(&rng.start); - // Scan the keys in the iterator - while iter.valid() { - // Check the scan limit - if res.len() < limit as usize { - // Get the key and value - let (k, v) = (iter.key(), iter.value()); - // Check the key and value - if let (Some(k), Some(v)) = (k, v) { - if k >= beg && k < end { - res.push((k.to_vec(), v.to_vec())); - iter.next(); - continue; - } + // Check the scan limit + while res.len() < limit as usize { + // Check the key and value + if let Some((k, v)) = iter.item() { + // Check the range validity + if k >= beg && k < end { + res.push((k.to_vec(), v.to_vec())); + iter.next(); + continue; } } // Exit