Avoid adding tombstones of the same file to RangeDelAggregator multiple times
Summary: RangeDelAggregator will remember the files whose range tombstones have been added, so the caller can check whether the file has been added before call AddTombstones. Closes https://github.com/facebook/rocksdb/pull/3635 Differential Revision: D7354604 Pulled By: ajkr fbshipit-source-id: 9b9f7ec130556028df417e650711554b46d8d107
This commit is contained in:
parent
7ffce2805b
commit
e80709a33a
@ -536,4 +536,11 @@ bool RangeDelAggregator::IsEmpty() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RangeDelAggregator::AddFile(uint64_t file_number) {
|
||||||
|
if (added_files_ == nullptr) {
|
||||||
|
added_files_.reset(new std::set<uint64_t>());
|
||||||
|
}
|
||||||
|
return added_files_->emplace(file_number).second;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace rocksdb
|
} // namespace rocksdb
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -140,6 +141,7 @@ class RangeDelAggregator {
|
|||||||
CompactionIterationStats* range_del_out_stats = nullptr,
|
CompactionIterationStats* range_del_out_stats = nullptr,
|
||||||
bool bottommost_level = false);
|
bool bottommost_level = false);
|
||||||
bool IsEmpty();
|
bool IsEmpty();
|
||||||
|
bool AddFile(uint64_t file_number);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Maps tombstone user start key -> tombstone object
|
// Maps tombstone user start key -> tombstone object
|
||||||
@ -180,6 +182,10 @@ class RangeDelAggregator {
|
|||||||
const InternalKeyComparator& icmp_;
|
const InternalKeyComparator& icmp_;
|
||||||
// collapse range deletions so they're binary searchable
|
// collapse range deletions so they're binary searchable
|
||||||
const bool collapse_deletions_;
|
const bool collapse_deletions_;
|
||||||
|
|
||||||
|
// Record files whose tombstones have been added, to avoid duplicate adding.
|
||||||
|
// Same as rep_, we initializes it lazily.
|
||||||
|
std::unique_ptr<std::set<uint64_t>> added_files_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace rocksdb
|
} // namespace rocksdb
|
||||||
|
@ -247,13 +247,15 @@ InternalIterator* TableCache::NewIterator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s.ok() && range_del_agg != nullptr && !options.ignore_range_deletions) {
|
if (s.ok() && range_del_agg != nullptr && !options.ignore_range_deletions) {
|
||||||
std::unique_ptr<InternalIterator> range_del_iter(
|
if (range_del_agg->AddFile(fd.GetNumber())) {
|
||||||
table_reader->NewRangeTombstoneIterator(options));
|
std::unique_ptr<InternalIterator> range_del_iter(
|
||||||
if (range_del_iter != nullptr) {
|
table_reader->NewRangeTombstoneIterator(options));
|
||||||
s = range_del_iter->status();
|
if (range_del_iter != nullptr) {
|
||||||
}
|
s = range_del_iter->status();
|
||||||
if (s.ok()) {
|
}
|
||||||
s = range_del_agg->AddTombstones(std::move(range_del_iter));
|
if (s.ok()) {
|
||||||
|
s = range_del_agg->AddTombstones(std::move(range_del_iter));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user