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
This commit is contained in:
parent
5cbb7e43e0
commit
9b8c9be0b5
@ -496,7 +496,6 @@ void ForwardIterator::RebuildIterators(bool refresh_sv) {
|
|||||||
l0_iters_.push_back(cfd_->table_cache()->NewIterator(
|
l0_iters_.push_back(cfd_->table_cache()->NewIterator(
|
||||||
read_options_, *cfd_->soptions(), cfd_->internal_comparator(), l0->fd));
|
read_options_, *cfd_->soptions(), cfd_->internal_comparator(), l0->fd));
|
||||||
}
|
}
|
||||||
level_iters_.reserve(vstorage->num_levels() - 1);
|
|
||||||
BuildLevelIterators(vstorage);
|
BuildLevelIterators(vstorage);
|
||||||
current_ = nullptr;
|
current_ = nullptr;
|
||||||
is_prev_set_ = false;
|
is_prev_set_ = false;
|
||||||
@ -560,6 +559,7 @@ void ForwardIterator::RenewIterators() {
|
|||||||
for (auto* l : level_iters_) {
|
for (auto* l : level_iters_) {
|
||||||
delete l;
|
delete l;
|
||||||
}
|
}
|
||||||
|
level_iters_.clear();
|
||||||
BuildLevelIterators(vstorage_new);
|
BuildLevelIterators(vstorage_new);
|
||||||
current_ = nullptr;
|
current_ = nullptr;
|
||||||
is_prev_set_ = false;
|
is_prev_set_ = false;
|
||||||
@ -568,6 +568,7 @@ void ForwardIterator::RenewIterators() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ForwardIterator::BuildLevelIterators(const VersionStorageInfo* vstorage) {
|
void ForwardIterator::BuildLevelIterators(const VersionStorageInfo* vstorage) {
|
||||||
|
level_iters_.reserve(vstorage->num_levels() - 1);
|
||||||
for (int32_t level = 1; level < vstorage->num_levels(); ++level) {
|
for (int32_t level = 1; level < vstorage->num_levels(); ++level) {
|
||||||
const auto& level_files = vstorage->LevelFiles(level);
|
const auto& level_files = vstorage->LevelFiles(level);
|
||||||
if ((level_files.empty()) ||
|
if ((level_files.empty()) ||
|
||||||
@ -575,13 +576,13 @@ void ForwardIterator::BuildLevelIterators(const VersionStorageInfo* vstorage) {
|
|||||||
(user_comparator_->Compare(*read_options_.iterate_upper_bound,
|
(user_comparator_->Compare(*read_options_.iterate_upper_bound,
|
||||||
level_files[0]->smallest.user_key()) <
|
level_files[0]->smallest.user_key()) <
|
||||||
0))) {
|
0))) {
|
||||||
|
level_iters_.push_back(nullptr);
|
||||||
if (!level_files.empty()) {
|
if (!level_files.empty()) {
|
||||||
level_iters_[level - 1] = nullptr;
|
|
||||||
has_iter_trimmed_for_upper_bound_ = true;
|
has_iter_trimmed_for_upper_bound_ = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
level_iters_[level - 1] =
|
level_iters_.push_back(
|
||||||
new LevelIterator(cfd_, read_options_, level_files);
|
new LevelIterator(cfd_, read_options_, level_files));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user