From eb2e48f019d63c52e46a351a082c6856788cac7d Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Wed, 22 Jul 2015 11:21:48 -0300 Subject: [PATCH] compaction: get compaction threshold from schema instead Get values from cf->schema instead of using hardcoded threshold values. In addition, move DEFAULT_MIN_COMPACTION_THRESHOLD and DEFAULT_MAX_COMPACTION_THRESHOLD to schema.hh so as not to have knowledge duplicated. Signed-off-by: Raphael S. Carvalho --- schema.hh | 7 +++++-- sstables/compaction.cc | 8 +++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/schema.hh b/schema.hh index 091444399e..349b400bf5 100644 --- a/schema.hh +++ b/schema.hh @@ -148,6 +148,9 @@ bool operator==(const column_definition&, const column_definition&); class schema_builder; +static constexpr int DEFAULT_MIN_COMPACTION_THRESHOLD = 4; +static constexpr int DEFAULT_MAX_COMPACTION_THRESHOLD = 32; + /* * Effectively immutable. * Not safe to access across cores because of shared_ptr's. @@ -175,8 +178,8 @@ private: int32_t _gc_grace_seconds = 864000; double _dc_local_read_repair_chance = 0.1; double _read_repair_chance = 0.0; - int32_t _min_compaction_threshold = 4; - int32_t _max_compaction_threshold = 32; + int32_t _min_compaction_threshold = DEFAULT_MIN_COMPACTION_THRESHOLD; + int32_t _max_compaction_threshold = DEFAULT_MAX_COMPACTION_THRESHOLD; int32_t _min_index_interval = 128; int32_t _max_index_interval = 2048; }; diff --git a/sstables/compaction.cc b/sstables/compaction.cc index 21254a11be..4326c48988 100644 --- a/sstables/compaction.cc +++ b/sstables/compaction.cc @@ -33,6 +33,7 @@ #include "compaction.hh" #include "compaction_strategy.hh" #include "mutation_reader.hh" +#include "schema.hh" namespace sstables { @@ -132,9 +133,6 @@ future<> compact_sstables(std::vector sstables, return read_done.then([write_done = std::move(write_done)] () mutable { return std::move(write_done); }); } -static constexpr int DEFAULT_MIN_COMPACTION_THRESHOLD = 4; -static constexpr int DEFAULT_MAX_COMPACTION_THRESHOLD = 32; - class compaction_strategy_impl { public: virtual ~compaction_strategy_impl() {} @@ -319,8 +317,8 @@ size_tiered_compaction_strategy::most_interesting_bucket(std::vector size_tiered_compaction_strategy::compact(column_family& cfs) { // make local copies so they can't be changed out from under us mid-method // FIXME: instead, we should get these values from column family. - int min_threshold = DEFAULT_MIN_COMPACTION_THRESHOLD; - int max_threshold = DEFAULT_MAX_COMPACTION_THRESHOLD; + int min_threshold = cfs.schema()->min_compaction_threshold(); + int max_threshold = cfs.schema()->max_compaction_threshold(); auto candidates = cfs.get_sstables();