mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-07 07:23:15 +00:00
dtcs: make code to extract non expired tables faster
since it's O(n) and not O(n log n). change also needed for change in interface of function to retrieve fully expired tables, or sort lambda would need to be parametrized. Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
This commit is contained in:
@@ -144,22 +144,13 @@ public:
|
||||
// Find fully expired SSTables. Those will be included no matter what.
|
||||
auto expired = get_fully_expired_sstables(cf, uncompacting, gc_before.time_since_epoch().count());
|
||||
|
||||
auto sort_ssts = [] (std::vector<sstables::shared_sstable>& sstables) {
|
||||
std::sort(sstables.begin(), sstables.end(), [] (const auto& x, const auto& y) {
|
||||
return x->generation() < y->generation();
|
||||
});
|
||||
};
|
||||
sort_ssts(uncompacting);
|
||||
sort_ssts(expired);
|
||||
if (!expired.empty()) {
|
||||
auto expired_as_set = boost::copy_range<std::unordered_set<sstables::shared_sstable>>(expired);
|
||||
auto is_expired = [&] (const sstables::shared_sstable& s) { return expired_as_set.find(s) != expired_as_set.end(); };
|
||||
uncompacting.erase(boost::remove_if(uncompacting, is_expired), uncompacting.end());
|
||||
}
|
||||
|
||||
std::vector<sstables::shared_sstable> non_expired_set;
|
||||
// Set non_expired_set with the elements that are in uncompacting, but not in the expired.
|
||||
std::set_difference(uncompacting.begin(), uncompacting.end(), expired.begin(), expired.end(),
|
||||
std::inserter(non_expired_set, non_expired_set.begin()), [] (const auto& x, const auto& y) {
|
||||
return x->generation() < y->generation();
|
||||
});
|
||||
|
||||
auto compaction_candidates = get_next_non_expired_sstables(cf, non_expired_set, gc_before);
|
||||
auto compaction_candidates = get_next_non_expired_sstables(cf, uncompacting, gc_before);
|
||||
if (!expired.empty()) {
|
||||
compaction_candidates.insert(compaction_candidates.end(), expired.begin(), expired.end());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user