From f0ee2356af356978a378be710e28a308ff34d9c5 Mon Sep 17 00:00:00 2001 From: sdong Date: Mon, 3 Mar 2014 16:35:32 -0800 Subject: [PATCH] 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 b135d01e7bcdf4186ea852a5b4e6d14a3a815d77 ). 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 --- table/merger.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/table/merger.cc b/table/merger.cc index 1aed00cc5..c154e6e64 100644 --- a/table/merger.cc +++ b/table/merger.cc @@ -122,6 +122,7 @@ class MergingIterator : public Iterator { // one, or null if there is no first child. current_ = first_child; } + direction_ = kForward; } virtual void Next() { @@ -228,6 +229,8 @@ class MergingIterator : public Iterator { // 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 // valid rows. + // This flag is always true for reverse direction, as we always use heap for + // the reverse iterating case. bool use_heap_; Env* const env_; // Which direction is the iterator moving?