kvdb-rocksdb: pass ReadOptions to iterators#277
Conversation
dvdplm
left a comment
There was a problem hiding this comment.
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: |
| { | ||
| 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.
<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>
dvdplm
left a comment
There was a problem hiding this comment.
There are still some docs that need some love, but overall lgtm.
| { | ||
| 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.
<insert illuminating example here>. – needs some editing... ;)
…and there are other methods that now take ReadOptions that needs some docs?
|
ping @bkchr |
bkchr
left a comment
There was a problem hiding this comment.
Besides the read lock in the comments it looks good.
| /// 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.
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_starthas 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.