Fix issue with iterator operations in this order: Prev(), Seek(), Prev()

Summary:
Due to a bad merge of D14163 and D14001 before checking in D14001, "direction_ = kForward;" in MergeIterator::Seek() was deleted my mistake (in commit b135d01e7b ). It will generate wrong results or assert failure after the sequence of Prev() (or SeekToLast()), Seek() and Prev().

Fix it

Test Plan: make all check

Reviewers: igor, haobo, dhruba

Reviewed By: igor

CC: yhchiang, i.am.jin.lei, ljin, leveldb

Differential Revision: https://reviews.facebook.net/D16527
This commit is contained in:
sdong 2014-03-03 16:35:32 -08:00
parent 5142b37000
commit f0ee2356af

View File

@ -122,6 +122,7 @@ class MergingIterator : public Iterator {
// one, or null if there is no first child. // one, or null if there is no first child.
current_ = first_child; current_ = first_child;
} }
direction_ = kForward;
} }
virtual void Next() { virtual void Next() {
@ -228,6 +229,8 @@ class MergingIterator : public Iterator {
// If the value is true, both of iterators in the heap and current_ // If the value is true, both of iterators in the heap and current_
// contain valid rows. If it is false, only current_ can possibly contain // contain valid rows. If it is false, only current_ can possibly contain
// valid rows. // valid rows.
// This flag is always true for reverse direction, as we always use heap for
// the reverse iterating case.
bool use_heap_; bool use_heap_;
Env* const env_; Env* const env_;
// Which direction is the iterator moving? // Which direction is the iterator moving?