Fix forward_iterator allocation of vector.

Summary:
db_tailing_iter_test was failing on some platforms because of
an incorrect allocation and use. This diff fixes the issue.

Test Plan:
db_tailing_iter_test
Run valgrind for db_tailing_iter_test

Reviewers: igor, sdong

Reviewed By: sdong

Subscribers: dhruba

Differential Revision: https://reviews.facebook.net/D50835
main
Venkatesh Radhakrishnan 9 years ago
parent 5cbb7e43e0
commit 9b8c9be0b5
  1. 9
      db/forward_iterator.cc

@ -496,7 +496,6 @@ void ForwardIterator::RebuildIterators(bool refresh_sv) {
l0_iters_.push_back(cfd_->table_cache()->NewIterator(
read_options_, *cfd_->soptions(), cfd_->internal_comparator(), l0->fd));
}
level_iters_.reserve(vstorage->num_levels() - 1);
BuildLevelIterators(vstorage);
current_ = nullptr;
is_prev_set_ = false;
@ -560,6 +559,7 @@ void ForwardIterator::RenewIterators() {
for (auto* l : level_iters_) {
delete l;
}
level_iters_.clear();
BuildLevelIterators(vstorage_new);
current_ = nullptr;
is_prev_set_ = false;
@ -568,6 +568,7 @@ void ForwardIterator::RenewIterators() {
}
void ForwardIterator::BuildLevelIterators(const VersionStorageInfo* vstorage) {
level_iters_.reserve(vstorage->num_levels() - 1);
for (int32_t level = 1; level < vstorage->num_levels(); ++level) {
const auto& level_files = vstorage->LevelFiles(level);
if ((level_files.empty()) ||
@ -575,13 +576,13 @@ void ForwardIterator::BuildLevelIterators(const VersionStorageInfo* vstorage) {
(user_comparator_->Compare(*read_options_.iterate_upper_bound,
level_files[0]->smallest.user_key()) <
0))) {
level_iters_.push_back(nullptr);
if (!level_files.empty()) {
level_iters_[level - 1] = nullptr;
has_iter_trimmed_for_upper_bound_ = true;
}
} else {
level_iters_[level - 1] =
new LevelIterator(cfd_, read_options_, level_files);
level_iters_.push_back(
new LevelIterator(cfd_, read_options_, level_files));
}
}
}

Loading…
Cancel
Save