diff --git a/sstables/compaction.hh b/sstables/compaction.hh index 094fe706f6..0e74220b6f 100644 --- a/sstables/compaction.hh +++ b/sstables/compaction.hh @@ -125,10 +125,6 @@ namespace sstables { uint64_t max_sstable_size, uint32_t sstable_level, seastar::thread_scheduling_group* tsg = nullptr); - // Return the most interesting bucket applying the size-tiered strategy. - std::vector - size_tiered_most_interesting_bucket(const std::vector& candidates); - // Return list of expired sstables for column family cf. // A sstable is fully expired *iff* its max_local_deletion_time precedes gc_before and its // max timestamp is lower than any other relevant sstable. diff --git a/sstables/compaction_strategy.cc b/sstables/compaction_strategy.cc index de47f9c35a..894b081801 100644 --- a/sstables/compaction_strategy.cc +++ b/sstables/compaction_strategy.cc @@ -391,18 +391,6 @@ public: } }; -std::vector -size_tiered_most_interesting_bucket(const std::vector& candidates) { - size_tiered_compaction_strategy cs; - - auto buckets = cs.get_buckets(candidates); - - std::vector most_interesting = cs.most_interesting_bucket(std::move(buckets), - DEFAULT_MIN_COMPACTION_THRESHOLD, DEFAULT_MAX_COMPACTION_THRESHOLD); - - return most_interesting; -} - compaction_strategy::compaction_strategy(::shared_ptr impl) : _compaction_strategy_impl(std::move(impl)) {} compaction_strategy::compaction_strategy() = default; diff --git a/sstables/leveled_manifest.hh b/sstables/leveled_manifest.hh index 043829677c..b5de72bcbd 100644 --- a/sstables/leveled_manifest.hh +++ b/sstables/leveled_manifest.hh @@ -43,6 +43,7 @@ #include "sstables.hh" #include "compaction.hh" +#include "size_tiered_compaction_strategy.hh" #include "range.hh" #include "log.hh" #include @@ -225,7 +226,7 @@ public: // before proceeding with a higher level, let's see if L0 is far enough behind to warrant STCS // TODO: we shouldn't proceed with size tiered strategy if cassandra.disable_stcs_in_l0 is true. if (get_level_size(0) > MAX_COMPACTING_L0) { - auto most_interesting = size_tiered_most_interesting_bucket(get_level(0)); + auto most_interesting = sstables::size_tiered_compaction_strategy::most_interesting_bucket(get_level(0)); if (!most_interesting.empty()) { logger.debug("L0 is too far behind, performing size-tiering there first"); return sstables::compaction_descriptor(std::move(most_interesting)); @@ -419,7 +420,7 @@ private: } else { // do STCS in L0 when max_sstable_size is high compared to size of new sstables, so we'll // avoid quadratic behavior until L0 is worth promoting. - candidates = size_tiered_most_interesting_bucket(get_level(0)); + candidates = sstables::size_tiered_compaction_strategy::most_interesting_bucket(get_level(0)); } return { std::move(candidates), can_promote }; } diff --git a/sstables/size_tiered_compaction_strategy.hh b/sstables/size_tiered_compaction_strategy.hh index fcbcf4f859..073a58f062 100644 --- a/sstables/size_tiered_compaction_strategy.hh +++ b/sstables/size_tiered_compaction_strategy.hh @@ -162,7 +162,9 @@ public: return compaction_strategy_type::size_tiered; } - friend std::vector size_tiered_most_interesting_bucket(const std::vector&); + // Return the most interesting bucket for a set of sstables + static std::vector + most_interesting_bucket(const std::vector& candidates); }; inline std::vector> @@ -328,4 +330,16 @@ inline int64_t size_tiered_compaction_strategy::estimated_pending_compactions(co return n; } +inline std::vector +size_tiered_compaction_strategy::most_interesting_bucket(const std::vector& candidates) { + size_tiered_compaction_strategy cs; + + auto buckets = cs.get_buckets(candidates); + + std::vector most_interesting = cs.most_interesting_bucket(std::move(buckets), + DEFAULT_MIN_COMPACTION_THRESHOLD, DEFAULT_MAX_COMPACTION_THRESHOLD); + + return most_interesting; +} + } diff --git a/sstables/time_window_compaction_strategy.hh b/sstables/time_window_compaction_strategy.hh index 8712663e6c..4dd85f1a17 100644 --- a/sstables/time_window_compaction_strategy.hh +++ b/sstables/time_window_compaction_strategy.hh @@ -245,7 +245,7 @@ public: if (bucket.size() >= size_t(min_threshold) && key >= now) { // If we're in the newest bucket, we'll use STCS to prioritize sstables - auto stcs_interesting_bucket = size_tiered_most_interesting_bucket(bucket); + auto stcs_interesting_bucket = size_tiered_compaction_strategy::most_interesting_bucket(bucket); // If the tables in the current bucket aren't eligible in the STCS strategy, we'll skip it and look for other buckets if (!stcs_interesting_bucket.empty()) { diff --git a/tests/sstable_datafile_test.cc b/tests/sstable_datafile_test.cc index b581803372..524dfc6ee5 100644 --- a/tests/sstable_datafile_test.cc +++ b/tests/sstable_datafile_test.cc @@ -1259,7 +1259,7 @@ static future> compact_sstables(std::vectorsize()); return sstables::compact_sstables(std::move(sstables_to_compact), *cf, new_sstable,