-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kvdb-rocksdb: pass ReadOptions to iterators #277
Conversation
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.
This is pretty confusing, apologies if I'm misunderstanding this.
In order to use prefix search users must create a prefix extractor (rocksdb::SliceTransform::create_fixed_prefix(…)
) when opening the DB and then pass it along when instantiating an iterator, is that correct?
The test_prefix_iterator()
test in rust-rocksdb
uses a different type though: Options
(i.e. ffi::rocksdb_options_t
) – do both work?
I think we have two options here:
- land this PR here (with more docs/examples illustrating usage)
- audit code using the prefix search and figure out if it really needs to; if, as I suspect, we're not using this, then maybe it's better to just remove support for it.
yes
|
what do you mean, we haven't changed the public API here |
no logic has changed But I just realised that we changed the logic in #257 8fb8f13#diff-4382bfb7e75959b2b8884268540abfa3R597, previously |
After a quick search, in parity-ethereum we use iter_from_prefix only in epoch_transitions and then we filter it to start with prefix here. The same thing happens in substrate: |
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.
lgtm modulo docs
kvdb-rocksdb/src/iter.rs
Outdated
} | ||
|
||
impl<'a, T> ReadGuardedIterator<'a, <&'a T as IterationHandler>::Iterator, T> | ||
where | ||
&'a T: IterationHandler, | ||
{ | ||
pub fn new(read_lock: RwLockReadGuard<'a, Option<T>>, col: Option<u32>) -> Self { | ||
Self { inner: Self::new_inner(read_lock, |db| db.iter(col)) } | ||
pub fn new(read_lock: RwLockReadGuard<'a, Option<T>>, col: Option<u32>, read_opts: &ReadOptions) -> Self { |
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.
docs
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.
<insert illuminating example here>.
– needs some editing... ;)
…and there are other methods that now take ReadOptions
that needs some docs?
Co-Authored-By: David <dvdplm@gmail.com>
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.
There are still some docs that need some love, but overall lgtm.
kvdb-rocksdb/src/iter.rs
Outdated
} | ||
|
||
impl<'a, T> ReadGuardedIterator<'a, <&'a T as IterationHandler>::Iterator, T> | ||
where | ||
&'a T: IterationHandler, | ||
{ | ||
pub fn new(read_lock: RwLockReadGuard<'a, Option<T>>, col: Option<u32>) -> Self { | ||
Self { inner: Self::new_inner(read_lock, |db| db.iter(col)) } | ||
pub fn new(read_lock: RwLockReadGuard<'a, Option<T>>, col: Option<u32>, read_opts: &ReadOptions) -> Self { |
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.
<insert illuminating example here>.
– needs some editing... ;)
…and there are other methods that now take ReadOptions
that needs some docs?
ping @bkchr |
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.
LGTM but I'm not super familiar with this code, thus would be good if @bkchr could sign off on it.
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.
Besides the read lock in the comments it looks good.
@@ -78,22 +84,35 @@ pub trait IterationHandler { | |||
|
|||
/// Create an `Iterator` over the default DB column or over a `ColumnFamily` if a column number | |||
/// is passed. | |||
fn iter(&self, col: u32) -> Self::Iterator; | |||
/// In addition to a read lock and a column index, it takes a ref to the same `ReadOptions` we |
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.
Not sure why it talks about the read lock here? That is not part of the interface?
Same below.
* master: kvdb-rocksdb: pass ReadOptions to iterators (#277)
Passing
prefix_same_as_start
has no effect, since we're not using "Prefix Seek" mode, see https://github.com/facebook/rocksdb/blob/9befbe9b406574e8d8b687799701bd8cebf5163b/include/rocksdb/options.h#L1246-L1251 and https://github.com/facebook/rocksdb/wiki/Prefix-Seek-API-Changes.