diff --git a/compaction/compaction_manager.cc b/compaction/compaction_manager.cc index c452d655a0..1eceaaf817 100644 --- a/compaction/compaction_manager.cc +++ b/compaction/compaction_manager.cc @@ -1175,7 +1175,7 @@ protected: table_state& t = *_compacting_table; sstables::compaction_strategy cs = t.get_compaction_strategy(); - sstables::compaction_descriptor descriptor = cs.get_sstables_for_compaction(t, _cm.get_strategy_control(), _cm.get_candidates(t)); + sstables::compaction_descriptor descriptor = cs.get_sstables_for_compaction(t, _cm.get_strategy_control()); int weight = calculate_weight(descriptor); if (descriptor.sstables.empty() || !can_proceed() || t.is_auto_compaction_disabled_by_user()) { @@ -1263,7 +1263,7 @@ future<> compaction_manager::maybe_wait_for_sstable_count_reduction(table_state& } auto num_runs_for_compaction = [&, this] { auto& cs = t.get_compaction_strategy(); - auto desc = cs.get_sstables_for_compaction(t, get_strategy_control(), get_candidates(t)); + auto desc = cs.get_sstables_for_compaction(t, get_strategy_control()); return boost::copy_range>( desc.sstables | boost::adaptors::transformed(std::mem_fn(&sstables::sstable::run_identifier))).size(); diff --git a/compaction/compaction_strategy.cc b/compaction/compaction_strategy.cc index 3793a86679..922b2917f6 100644 --- a/compaction/compaction_strategy.cc +++ b/compaction/compaction_strategy.cc @@ -548,7 +548,7 @@ struct null_backlog_tracker final : public compaction_backlog_tracker::impl { // class null_compaction_strategy : public compaction_strategy_impl { public: - virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector candidates) override { + virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control) override { return sstables::compaction_descriptor(); } @@ -667,8 +667,8 @@ compaction_strategy_type compaction_strategy::type() const { return _compaction_strategy_impl->type(); } -compaction_descriptor compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector candidates) { - return _compaction_strategy_impl->get_sstables_for_compaction(table_s, control, std::move(candidates)); +compaction_descriptor compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control) { + return _compaction_strategy_impl->get_sstables_for_compaction(table_s, control); } compaction_descriptor compaction_strategy::get_major_compaction_job(table_state& table_s, std::vector candidates) { diff --git a/compaction/compaction_strategy.hh b/compaction/compaction_strategy.hh index 212f59b5a8..d734ef7d67 100644 --- a/compaction/compaction_strategy.hh +++ b/compaction/compaction_strategy.hh @@ -44,7 +44,7 @@ public: compaction_strategy& operator=(compaction_strategy&&); // Return a list of sstables to be compacted after applying the strategy. - compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector candidates); + compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control); compaction_descriptor get_major_compaction_job(table_state& table_s, std::vector candidates); diff --git a/compaction/compaction_strategy_impl.hh b/compaction/compaction_strategy_impl.hh index 24c21d5f8f..f5438e7999 100644 --- a/compaction/compaction_strategy_impl.hh +++ b/compaction/compaction_strategy_impl.hh @@ -45,7 +45,7 @@ protected: uint64_t max_sstable_bytes = compaction_descriptor::default_max_sstable_bytes); public: virtual ~compaction_strategy_impl() {} - virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector candidates) = 0; + virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control) = 0; virtual compaction_descriptor get_major_compaction_job(table_state& table_s, std::vector candidates) { return make_major_compaction_job(std::move(candidates)); } diff --git a/compaction/leveled_compaction_strategy.cc b/compaction/leveled_compaction_strategy.cc index 925bcdd2e4..6766cf5a1d 100644 --- a/compaction/leveled_compaction_strategy.cc +++ b/compaction/leveled_compaction_strategy.cc @@ -19,8 +19,9 @@ leveled_compaction_strategy_state& leveled_compaction_strategy::get_state(table_ return table_s.get_compaction_strategy_state().get(); } -compaction_descriptor leveled_compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector candidates) { +compaction_descriptor leveled_compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control) { auto& state = get_state(table_s); + auto candidates = control.candidates(table_s); // NOTE: leveled_manifest creation may be slightly expensive, so later on, // we may want to store it in the strategy itself. However, the sstable // lists managed by the manifest may become outdated. For example, one diff --git a/compaction/leveled_compaction_strategy.hh b/compaction/leveled_compaction_strategy.hh index 2ca57e826c..d38ed07e0b 100644 --- a/compaction/leveled_compaction_strategy.hh +++ b/compaction/leveled_compaction_strategy.hh @@ -49,7 +49,7 @@ public: static void validate_options(const std::map& options, std::map& unchecked_options); leveled_compaction_strategy(const std::map& options); - virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector candidates) override; + virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control) override; virtual std::vector get_cleanup_compaction_jobs(table_state& table_s, std::vector candidates) const override; diff --git a/compaction/size_tiered_compaction_strategy.cc b/compaction/size_tiered_compaction_strategy.cc index d06563bf91..bf6bfcbabc 100644 --- a/compaction/size_tiered_compaction_strategy.cc +++ b/compaction/size_tiered_compaction_strategy.cc @@ -210,11 +210,12 @@ size_tiered_compaction_strategy::most_interesting_bucket(std::vector candidates) { +size_tiered_compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control) { // make local copies so they can't be changed out from under us mid-method int min_threshold = table_s.min_compaction_threshold(); int max_threshold = table_s.schema()->max_compaction_threshold(); auto compaction_time = gc_clock::now(); + auto candidates = control.candidates(table_s); // TODO: Add support to filter cold sstables (for reference: SizeTieredCompactionStrategy::filterColdSSTables). diff --git a/compaction/size_tiered_compaction_strategy.hh b/compaction/size_tiered_compaction_strategy.hh index eb9ccef189..a2bc7f3d28 100644 --- a/compaction/size_tiered_compaction_strategy.hh +++ b/compaction/size_tiered_compaction_strategy.hh @@ -77,7 +77,7 @@ public: explicit size_tiered_compaction_strategy(const size_tiered_compaction_strategy_options& options); static void validate_options(const std::map& options, std::map& unchecked_options); - virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector candidates) override; + virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control) override; virtual std::vector get_cleanup_compaction_jobs(table_state& table_s, std::vector candidates) const override; diff --git a/compaction/time_window_compaction_strategy.cc b/compaction/time_window_compaction_strategy.cc index 7fa35a5ec6..45e34780b4 100644 --- a/compaction/time_window_compaction_strategy.cc +++ b/compaction/time_window_compaction_strategy.cc @@ -301,9 +301,10 @@ time_window_compaction_strategy::get_reshaping_job(std::vector i } compaction_descriptor -time_window_compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector candidates) { +time_window_compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control) { auto& state = get_state(table_s); auto compaction_time = gc_clock::now(); + auto candidates = control.candidates(table_s); if (candidates.empty()) { state.estimated_remaining_tasks = 0; diff --git a/compaction/time_window_compaction_strategy.hh b/compaction/time_window_compaction_strategy.hh index 01d0ac446c..28361f3466 100644 --- a/compaction/time_window_compaction_strategy.hh +++ b/compaction/time_window_compaction_strategy.hh @@ -83,7 +83,7 @@ public: enum class bucket_compaction_mode { none, size_tiered, major }; public: time_window_compaction_strategy(const std::map& options); - virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector candidates) override; + virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control) override; virtual std::vector get_cleanup_compaction_jobs(table_state& table_s, std::vector candidates) const override; diff --git a/test/boost/sstable_compaction_test.cc b/test/boost/sstable_compaction_test.cc index 468f3165d3..d8b58951a3 100644 --- a/test/boost/sstable_compaction_test.cc +++ b/test/boost/sstable_compaction_test.cc @@ -144,11 +144,11 @@ static std::unique_ptr make_strategy_control_for_test(bool has template requires requires(CompactionStrategy cs, table_state& t, strategy_control& c) { - { cs.get_sstables_for_compaction(t, c, std::vector()) } -> std::same_as; + { cs.get_sstables_for_compaction(t, c) } -> std::same_as; } static compaction_descriptor get_sstables_for_compaction(CompactionStrategy& cs, table_state& t, std::vector candidates) { auto control = make_strategy_control_for_test(false, std::move(candidates)); - return cs.get_sstables_for_compaction(t, *control, control->candidates(t)); + return cs.get_sstables_for_compaction(t, *control); } static void assert_table_sstable_count(table_for_tests& t, size_t expected_count) { diff --git a/test/lib/sstable_run_based_compaction_strategy_for_tests.cc b/test/lib/sstable_run_based_compaction_strategy_for_tests.cc index 38947f0598..69a3e7b579 100644 --- a/test/lib/sstable_run_based_compaction_strategy_for_tests.cc +++ b/test/lib/sstable_run_based_compaction_strategy_for_tests.cc @@ -13,7 +13,7 @@ namespace sstables { sstable_run_based_compaction_strategy_for_tests::sstable_run_based_compaction_strategy_for_tests() = default; -compaction_descriptor sstable_run_based_compaction_strategy_for_tests::get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector uncompacting_sstables) { +compaction_descriptor sstable_run_based_compaction_strategy_for_tests::get_sstables_for_compaction(table_state& table_s, strategy_control& control) { // Get unique runs from all uncompacting sstables std::vector runs = table_s.main_sstable_set().all_sstable_runs(); diff --git a/test/lib/sstable_run_based_compaction_strategy_for_tests.hh b/test/lib/sstable_run_based_compaction_strategy_for_tests.hh index 2bfba8895f..9715f1a528 100644 --- a/test/lib/sstable_run_based_compaction_strategy_for_tests.hh +++ b/test/lib/sstable_run_based_compaction_strategy_for_tests.hh @@ -22,7 +22,7 @@ class sstable_run_based_compaction_strategy_for_tests : public compaction_strate public: sstable_run_based_compaction_strategy_for_tests(); - virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector uncompacting_sstables) override; + virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control) override; virtual int64_t estimated_pending_compactions(table_state& table_s) const override;