SequenceIterWrapper should use internal comparator (#8328)

Summary:
https://github.com/facebook/rocksdb/pull/8288 introduces a bug: SequenceIterWrapper should do next for seek key using internal key comparator rather than user comparator. Fix it.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8328

Test Plan: Pass all existing tests

Reviewed By: ltamasi

Differential Revision: D28647263

fbshipit-source-id: 4081d684fd8a86d248c485ef8a1563c7af136447
This commit is contained in:
sdong 2021-05-24 12:45:35 -07:00 committed by Facebook GitHub Bot
parent a4405fd981
commit a607b88240
1 changed files with 5 additions and 3 deletions

View File

@ -30,7 +30,9 @@ class SequenceIterWrapper : public InternalIterator {
public:
SequenceIterWrapper(InternalIterator* iter, const Comparator* cmp,
bool need_count_entries)
: cmp_(cmp), inner_iter_(iter), need_count_entries_(need_count_entries) {}
: icmp_(cmp, /*named=*/false),
inner_iter_(iter),
need_count_entries_(need_count_entries) {}
bool Valid() const override { return inner_iter_->Valid(); }
Status status() const override { return inner_iter_->status(); }
void Next() override {
@ -44,7 +46,7 @@ class SequenceIterWrapper : public InternalIterator {
// For flush cases, we need to count total number of entries, so we
// do Next() rather than Seek().
while (inner_iter_->Valid() &&
cmp_->Compare(inner_iter_->key(), target) < 0) {
icmp_.Compare(inner_iter_->key(), target) < 0) {
Next();
}
}
@ -61,7 +63,7 @@ class SequenceIterWrapper : public InternalIterator {
uint64_t num_itered() const { return num_itered_; }
private:
const Comparator* cmp_; // not owned
InternalKeyComparator icmp_;
InternalIterator* inner_iter_; // not owned
uint64_t num_itered_ = 0;
bool need_count_entries_;