-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Iterate over both buffered and unbuffered database entries #6860
Conversation
It looks like @efyang hasn'signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement at the following URL: https://cla.parity.io Once you've signed, plesae reply to this thread with Many thanks, Parity Technologies CLA Bot |
[clabot:check] |
It looks like @efyang signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
util/kvdb-rocksdb/src/lib.rs
Outdated
match *self.db.read() { | ||
Some(DBAndColumns { ref db, ref cfs }) => { | ||
let overlay = &self.overlay.read()[Self::to_overlay_column(col)]; | ||
let overlay_data = overlay.iter() | ||
.filter_map(|(k, v)| match v { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use match *
instead of prefixing every option with &
:
match *v {
KeyState::Insert(ref value) => {
}
util/kvdb-rocksdb/src/lib.rs
Outdated
&KeyState::InsertCompressed(ref value) => | ||
Some((k.clone().into_vec().into_boxed_slice(), value.clone().into_vec().into_boxed_slice())), | ||
&KeyState::Delete => None, | ||
}).collect::<Vec<_>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to allocate here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having trouble finding some other way to convert elasticarray
's to boxed slices.
util/kvdb-rocksdb/src/lib.rs
Outdated
match *self.db.read() { | ||
Some(DBAndColumns { ref db, ref cfs }) => { | ||
let overlay = &self.overlay.read()[Self::to_overlay_column(col)]; | ||
let overlay_data = overlay.iter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hashmap iterators aren't ordered, so interleave-ordered behavior probably won't be right there.
@@ -536,7 +547,7 @@ impl Database { | |||
.expect("iterator params are valid; qed")); | |||
|
|||
Some(DatabaseIterator { | |||
iter: iter, | |||
iter: interleave_ordered(Vec::new(), iter), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should use std::iter::empty
instead of Vec::new
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, I see that types would not match
merged and reopened on top of latest master in #7048 |
Closes #6048.