Fix regression failure in PrefixTest.PrefixValid

Summary: Use IterKey to store prefix_start_ so that it doesn't get freed

Test Plan: PrefixTest.PrefixValid

Reviewers: anthony, IslamAbdelRahman

Reviewed By: IslamAbdelRahman

Subscribers: dhruba

Differential Revision: https://reviews.facebook.net/D50289
main
Venkatesh Radhakrishnan 9 years ago
parent c8e01ef982
commit ae7940b628
  1. 12
      db/db_iter.cc

@ -157,7 +157,7 @@ class DBIter: public Iterator {
Statistics* statistics_; Statistics* statistics_;
uint64_t max_skip_; uint64_t max_skip_;
const Slice* iterate_upper_bound_; const Slice* iterate_upper_bound_;
Slice prefix_start_; IterKey prefix_start_;
bool prefix_same_as_start_; bool prefix_same_as_start_;
// No copying allowed // No copying allowed
@ -203,7 +203,7 @@ void DBIter::Next() {
} }
if (valid_ && prefix_extractor_ && prefix_same_as_start_ && if (valid_ && prefix_extractor_ && prefix_same_as_start_ &&
prefix_extractor_->Transform(saved_key_.GetKey()) prefix_extractor_->Transform(saved_key_.GetKey())
.compare(prefix_start_) != 0) { .compare(prefix_start_.GetKey()) != 0) {
valid_ = false; valid_ = false;
} }
} }
@ -378,7 +378,7 @@ void DBIter::Prev() {
} }
if (valid_ && prefix_extractor_ && prefix_same_as_start_ && if (valid_ && prefix_extractor_ && prefix_same_as_start_ &&
prefix_extractor_->Transform(saved_key_.GetKey()) prefix_extractor_->Transform(saved_key_.GetKey())
.compare(prefix_start_) != 0) { .compare(prefix_start_.GetKey()) != 0) {
valid_ = false; valid_ = false;
} }
} }
@ -683,7 +683,7 @@ void DBIter::Seek(const Slice& target) {
valid_ = false; valid_ = false;
} }
if (valid_ && prefix_extractor_ && prefix_same_as_start_) { if (valid_ && prefix_extractor_ && prefix_same_as_start_) {
prefix_start_ = prefix_extractor_->Transform(target); prefix_start_.SetKey(prefix_extractor_->Transform(target));
} }
} }
@ -714,7 +714,7 @@ void DBIter::SeekToFirst() {
valid_ = false; valid_ = false;
} }
if (valid_ && prefix_extractor_ && prefix_same_as_start_) { if (valid_ && prefix_extractor_ && prefix_same_as_start_) {
prefix_start_ = prefix_extractor_->Transform(saved_key_.GetKey()); prefix_start_.SetKey(prefix_extractor_->Transform(saved_key_.GetKey()));
} }
} }
@ -762,7 +762,7 @@ void DBIter::SeekToLast() {
} }
} }
if (valid_ && prefix_extractor_ && prefix_same_as_start_) { if (valid_ && prefix_extractor_ && prefix_same_as_start_) {
prefix_start_ = prefix_extractor_->Transform(saved_key_.GetKey()); prefix_start_.SetKey(prefix_extractor_->Transform(saved_key_.GetKey()));
} }
} }

Loading…
Cancel
Save