File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,14 +95,18 @@ class Iterator : public IteratorBase {
9595 return Slice ();
9696 }
9797
98- // RocksDB Internal - DO NOT USE
99- // Prepare the iterator to scan the ranges specified in scan_opts. The
100- // upper bound and other table specific limits may be specified. This will
101- // typically be followed by Seeks to the start keys in the order they're
102- // specified in scan_opts. If the user does a Seek to some other target key,
103- // the iterator should disregard the scan_opts from that point onwards and
104- // behave like a normal iterator. Its the user's responsibility to again
105- // call Prepare().
98+ // Prepare the iterator to scan the ranges specified in scan_opts. This
99+ // includes prefetching relevant blocks from disk. The upper bound and
100+ // other table specific limits should be specified for each
101+ // scan for best results. If an upper bound is not specified, Prepare may
102+ // skip prefetching as it cannot accurately determine how much to prefetch.
103+ //
104+ // Prepare should typically be followed by Seeks to the start keys in the
105+ // order they're specified in scan_opts. If the user does a Seek to some
106+ // other target key, the iterator should disregard the scan_opts from that
107+ // point onwards and behave like a normal iterator. Its the user's
108+ // responsibility to again call Prepare().
109+ //
106110 // If Prepare() is called, it overrides the iterate_upper_bound in
107111 // ReadOptions
108112 virtual void Prepare (const std::vector<ScanOptions>& /* scan_opts*/ ) {}
Original file line number Diff line number Diff line change @@ -89,6 +89,10 @@ class UserDefinedIndexIterator {
8989 public:
9090 virtual ~UserDefinedIndexIterator () = default ;
9191
92+ // Prepare the iterator for a series of scans. The iterator should use
93+ // this as an opportunity to do any prefetching and buffering of results.
94+ virtual void Prepare (const ScanOptions scan_opts[], size_t num_opts) = 0;
95+
9296 // Given the target key, position the index iterator at the index entry
9397 // with the smallest key >= target. The result must be updated with the
9498 // index key, and the bound_check_result. The bound_check_result should
Original file line number Diff line number Diff line change @@ -222,6 +222,10 @@ class BlockBasedTableIterator : public InternalIteratorBase<Slice> {
222222 }
223223 }
224224
225+ void Prepare (const std::vector<ScanOptions>* scan_opts) override {
226+ index_iter_->Prepare (scan_opts);
227+ }
228+
225229 FilePrefetchBuffer* prefetch_buffer () {
226230 return block_prefetcher_.prefetch_buffer ();
227231 }
Original file line number Diff line number Diff line change @@ -181,6 +181,10 @@ class UserDefinedIndexIteratorWrapper
181181
182182 Status status () const override { return status_; }
183183
184+ void Prepare (const std::vector<ScanOptions>* scan_opts) override {
185+ udi_iter_->Prepare (scan_opts->data (), scan_opts->size ());
186+ }
187+
184188 private:
185189 std::unique_ptr<UserDefinedIndexIterator> udi_iter_;
186190 IterateResult result_;
You can’t perform that action at this time.
0 commit comments