From 3dc1821287bc9d00f0dbb4fec998f82fbc5e3835 Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Mon, 20 Sep 2021 15:16:38 -0300 Subject: [PATCH] compaction: introduce compaction_read_monitor_generator::remove_exhausted_sstables() This new function makes it easier to remove monitor of exhausted sstables. Signed-off-by: Raphael S. Carvalho --- compaction/compaction.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/compaction/compaction.cc b/compaction/compaction.cc index 22d093e94a..5801f48060 100644 --- a/compaction/compaction.cc +++ b/compaction/compaction.cc @@ -381,11 +381,13 @@ struct compaction_read_monitor_generator final : public read_monitor_generator { } } - void remove_sstable(bool is_tracking, sstables::shared_sstable& sst) { - auto it = _generated_monitors.find(sst); - if (it != _generated_monitors.end()) { - it->second.remove_sstable(is_tracking); - _generated_monitors.erase(it); + void remove_exhausted_sstables(bool is_tracking, const std::vector& exhausted_sstables) { + for (auto &sst : exhausted_sstables) { + auto it = _generated_monitors.find(sst); + if (it != _generated_monitors.end()) { + it->second.remove_sstable(is_tracking); + _generated_monitors.erase(it); + } } } private: @@ -1040,9 +1042,7 @@ private: // an early sstable replacement. // - for (auto& sst : exhausted_sstables) { - _monitor_generator.remove_sstable(_info->tracking, sst); - } + _monitor_generator.remove_exhausted_sstables(_info->tracking, exhausted_sstables); auto& tracker = _cf.get_compaction_strategy().get_backlog_tracker(); for (auto& sst : _unused_sstables) { tracker.add_sstable(sst);