From f84148c3357514bacbd1ca094c51b4d216e727ee Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Wed, 8 Jul 2015 14:51:29 -0400 Subject: [PATCH 1/6] schema: support cf type, and is_super All CFMetaData has a type, either Standard or Super. Right now, we do not support Super, but we still would like to query for it, and use that information to build our schemas. Signed-off-by: Glauber Costa --- db/legacy_schema_tables.cc | 45 ++++++++++++++++++++------------------ db/legacy_schema_tables.hh | 12 +++++----- schema.hh | 33 ++++++++++++++++++++++++++++ unimplemented.cc | 1 + unimplemented.hh | 1 + 5 files changed, 65 insertions(+), 27 deletions(-) diff --git a/db/legacy_schema_tables.cc b/db/legacy_schema_tables.cc index 6ba5ce8382..9098b1f5b0 100644 --- a/db/legacy_schema_tables.cc +++ b/db/legacy_schema_tables.cc @@ -1001,25 +1001,20 @@ future<> save_system_keyspace_schema() { mutation m{pkey, s}; auto ckey = clustering_key::from_single_value(*s, to_bytes(table->cf_name())); m.set_clustered_cell(ckey, "cf_id", table->id(), timestamp); + m.set_clustered_cell(ckey, "type", cf_type_to_sstring(table->type()), timestamp); + + if (table->is_super()) { + warn(unimplemented::cause::SUPER); #if 0 - m.set_clustered_cell(ckey, "type", table.cfType.toString(), timestamp); -#endif -#if 0 - if (table.isSuper()) - { // We need to continue saving the comparator and subcomparator separatly, otherwise // we won't know at deserialization if the subcomparator should be taken into account // TODO: we should implement an on-start migration if we want to get rid of that. adder.add("comparator", table.comparator.subtype(0).toString()); adder.add("subcomparator", table.comparator.subtype(1).toString()); - } - else - { #endif + } else { m.set_clustered_cell(ckey, "comparator", table->regular_column_name_type()->name(), timestamp); -#if 0 } -#endif m.set_clustered_cell(ckey, "bloom_filter_fp_chance", table->bloom_filter_fp_chance(), timestamp); #if 0 @@ -1225,16 +1220,24 @@ future<> save_system_keyspace_schema() { #if 0 AbstractType rawComparator = TypeParser.parse(result.getString("comparator")); AbstractType subComparator = result.has("subcomparator") ? TypeParser.parse(result.getString("subcomparator")) : null; - ColumnFamilyType cfType = ColumnFamilyType.valueOf(result.getString("type")); +#endif + cf_type cf = cf_type::standard; + if (table_row.has("type")) { + cf = sstring_to_cf_type(table_row.get_nonnull("type")); + if (cf == cf_type::super) { + fail(unimplemented::cause::SUPER); + } + } +#if 0 AbstractType fullRawComparator = CFMetaData.makeRawAbstractType(rawComparator, subComparator); #endif std::vector column_defs = create_columns_from_column_rows(serialized_column_definitions, ks_name, - cf_name/*, - fullRawComparator, - cfType == ColumnFamilyType.Super*/); + cf_name,/*, + fullRawComparator, */ + cf == cf_type::super); bool is_dense; if (table_row.has("is_dense")) { @@ -1383,22 +1386,22 @@ future<> save_system_keyspace_schema() { std::vector create_columns_from_column_rows(const schema_result::mapped_type& rows, const sstring& keyspace, - const sstring& table/*, - AbstractType rawComparator, - boolean isSuper*/) + const sstring& table, /*, + AbstractType rawComparator, */ + bool is_super) { std::vector columns; for (auto&& row : rows->rows()) { - columns.emplace_back(std::move(create_column_from_column_row(row, keyspace, table/*, rawComparator, isSuper*/))); + columns.emplace_back(std::move(create_column_from_column_row(row, keyspace, table, /*, rawComparator, */ is_super))); } return columns; } column_definition create_column_from_column_row(const query::result_set_row& row, sstring keyspace, - sstring table/*, - AbstractType rawComparator, - boolean isSuper*/) + sstring table, /*, + AbstractType rawComparator, */ + bool is_super) { auto kind = deserialize_kind(row.get_nonnull("type")); diff --git a/db/legacy_schema_tables.hh b/db/legacy_schema_tables.hh index bc81ddc46c..c83074f9d7 100644 --- a/db/legacy_schema_tables.hh +++ b/db/legacy_schema_tables.hh @@ -85,15 +85,15 @@ void create_table_from_table_row_and_column_rows(schema_builder& builder, const std::vector create_columns_from_column_rows(const schema_result::mapped_type& rows, const sstring& keyspace, - const sstring& table/*, - AbstractType rawComparator, - boolean isSuper*/); + const sstring& table,/*, + AbstractType rawComparator, */ + bool is_super); column_definition create_column_from_column_row(const query::result_set_row& row, sstring keyspace, - sstring table/*, - AbstractType rawComparator, - boolean isSuper*/); + sstring table, /*, + AbstractType rawComparator, */ + bool is_super); void add_column_to_schema_mutation(schema_ptr table, const column_definition& column, api::timestamp_type timestamp, const partition_key& pkey, std::vector& mutations); diff --git a/schema.hh b/schema.hh index 0d92b2fb2d..329bfa4397 100644 --- a/schema.hh +++ b/schema.hh @@ -31,6 +31,29 @@ enum class index_type { none, // cwi: added none to avoid "optional" bs. }; +enum class cf_type : uint8_t { + standard, + super, +}; + +inline sstring cf_type_to_sstring(cf_type t) { + if (t == cf_type::standard) { + return "Standard"; + } else if (t == cf_type::super) { + return "Super"; + } + throw std::invalid_argument(sprint("unknown type: %d\n", uint8_t(t))); +} + +inline cf_type sstring_to_cf_type(sstring name) { + if (name == "Standard") { + return cf_type::standard; + } else if (name == "Super") { + return cf_type::super; + } + throw std::invalid_argument(sprint("unknown type: %s\n", name)); +} + typedef std::unordered_map index_options_map; class schema; @@ -149,6 +172,7 @@ private: double _bloom_filter_fp_chance = 0.01; compression_parameters _compressor_params; bool _is_dense = false; + cf_type _type = cf_type::standard; }; raw_schema _raw; thrift_schema _thrift; @@ -235,6 +259,15 @@ public: bool is_counter() const { return false; } + + const cf_type type() const { + return _raw._type; + } + + bool is_super() const { + return _raw._type == cf_type::super; + } + const column_definition* get_column_definition(const bytes& name) const; const_iterator regular_begin() const { return regular_columns().begin(); diff --git a/unimplemented.cc b/unimplemented.cc index 2454db096d..83b0ec869b 100644 --- a/unimplemented.cc +++ b/unimplemented.cc @@ -36,6 +36,7 @@ std::ostream& operator<<(std::ostream& out, cause c) { case cause::NONATOMIC: return out << "NONATOMIC"; case cause::CONSISTENCY: return out << "CONSISTENCY"; case cause::HINT: return out << "HINT"; + case cause::SUPER: return out << "SUPER"; } assert(0); } diff --git a/unimplemented.hh b/unimplemented.hh index c7d0aeeb70..c707d41666 100644 --- a/unimplemented.hh +++ b/unimplemented.hh @@ -35,6 +35,7 @@ enum class cause { NONATOMIC, CONSISTENCY, HINT, + SUPER, }; void fail(cause what) __attribute__((noreturn)); From 8218c819a5a29951a390a947cb9bd9797e5a017a Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Wed, 8 Jul 2015 15:02:14 -0400 Subject: [PATCH 2/6] schema: access gc_grace_seconds Signed-off-by: Glauber Costa --- cql3/statements/cf_prop_defs.hh | 6 +++++- db/legacy_schema_tables.cc | 9 +++++---- schema.hh | 5 +++++ schema_builder.hh | 8 ++++++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/cql3/statements/cf_prop_defs.hh b/cql3/statements/cf_prop_defs.hh index 3843e57f27..ed36e203fa 100644 --- a/cql3/statements/cf_prop_defs.hh +++ b/cql3/statements/cf_prop_defs.hh @@ -168,7 +168,11 @@ public: #if 0 cfm.readRepairChance(getDouble(KW_READREPAIRCHANCE, cfm.getReadRepairChance())); cfm.dcLocalReadRepairChance(getDouble(KW_DCLOCALREADREPAIRCHANCE, cfm.getDcLocalReadRepairChance())); - cfm.gcGraceSeconds(getInt(KW_GCGRACESECONDS, cfm.getGcGraceSeconds())); +#endif + if (has_property(KW_GCGRACESECONDS)) { + builder.set_gc_grace_seconds(get_int(KW_GCGRACESECONDS, builder.get_gc_grace_seconds())); + } +#if 0 int minCompactionThreshold = toInt(KW_MINCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MINCOMPACTIONTHRESHOLD), cfm.getMinCompactionThreshold()); int maxCompactionThreshold = toInt(KW_MAXCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MAXCOMPACTIONTHRESHOLD), cfm.getMaxCompactionThreshold()); if (minCompactionThreshold <= 0 || maxCompactionThreshold <= 0) diff --git a/db/legacy_schema_tables.cc b/db/legacy_schema_tables.cc index 9098b1f5b0..f31f23b615 100644 --- a/db/legacy_schema_tables.cc +++ b/db/legacy_schema_tables.cc @@ -1029,9 +1029,7 @@ future<> save_system_keyspace_schema() { m.set_clustered_cell(ckey, "compression_parameters", json::to_json(compression_options.get_options()), timestamp); m.set_clustered_cell(ckey, "default_time_to_live", table->default_time_to_live().count(), timestamp); m.set_clustered_cell(ckey, "default_validator", table->default_validator()->name(), timestamp); -#if 0 - adder.add("gc_grace_seconds", table.getGcGraceSeconds()); -#endif + m.set_clustered_cell(ckey, "gc_grace_seconds", table->gc_grace_seconds(), timestamp); m.set_clustered_cell(ckey, "key_validator", table->thrift_key_validator(), timestamp); #if 0 adder.add("local_read_repair_chance", table.getDcLocalReadRepairChance()); @@ -1263,8 +1261,11 @@ future<> save_system_keyspace_schema() { #if 0 cfm.readRepairChance(result.getDouble("read_repair_chance")); cfm.dcLocalReadRepairChance(result.getDouble("local_read_repair_chance")); - cfm.gcGraceSeconds(result.getInt("gc_grace_seconds")); #endif + if (table_row.has("gc_grace_seconds")) { + builder.set_gc_grace_seconds(table_row.get_nonnull("gc_grace_seconds")); + } + if (table_row.has("default_validator")) { builder.set_default_validator(parse_type(table_row.get_nonnull("default_validator"))); } diff --git a/schema.hh b/schema.hh index 329bfa4397..97a49618aa 100644 --- a/schema.hh +++ b/schema.hh @@ -173,6 +173,7 @@ private: compression_parameters _compressor_params; bool _is_dense = false; cf_type _type = cf_type::standard; + int32_t _gc_grace_seconds = 864000; }; raw_schema _raw; thrift_schema _thrift; @@ -268,6 +269,10 @@ public: return _raw._type == cf_type::super; } + int32_t gc_grace_seconds() const { + return _raw._gc_grace_seconds; + } + const column_definition* get_column_definition(const bytes& name) const; const_iterator regular_begin() const { return regular_columns().begin(); diff --git a/schema_builder.hh b/schema_builder.hh index 6711b396f6..568289a824 100644 --- a/schema_builder.hh +++ b/schema_builder.hh @@ -52,6 +52,14 @@ public: _raw._default_validator = validator; } + void set_gc_grace_seconds(int32_t gc_grace_seconds) { + _raw._gc_grace_seconds = gc_grace_seconds; + } + + int32_t get_gc_grace_seconds() { + return _raw._gc_grace_seconds; + } + void set_bloom_filter_fp_chance(double fp) { _raw._bloom_filter_fp_chance = fp; } From b75bd9ef5308e4c09ffcca0ae23cbf0b1ff306c0 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Wed, 8 Jul 2015 16:20:20 -0400 Subject: [PATCH 3/6] schema: add local_repair_chance parameter Signed-off-by: Glauber Costa --- cql3/statements/cf_prop_defs.hh | 5 ++++- db/legacy_schema_tables.cc | 7 +++++-- schema.hh | 5 +++++ schema_builder.hh | 8 ++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/cql3/statements/cf_prop_defs.hh b/cql3/statements/cf_prop_defs.hh index ed36e203fa..d62cf9ef64 100644 --- a/cql3/statements/cf_prop_defs.hh +++ b/cql3/statements/cf_prop_defs.hh @@ -167,8 +167,11 @@ public: } #if 0 cfm.readRepairChance(getDouble(KW_READREPAIRCHANCE, cfm.getReadRepairChance())); - cfm.dcLocalReadRepairChance(getDouble(KW_DCLOCALREADREPAIRCHANCE, cfm.getDcLocalReadRepairChance())); #endif + if (has_property(KW_DCLOCALREADREPAIRCHANCE)) { + builder.set_dc_local_read_repair_chance(get_double(KW_DCLOCALREADREPAIRCHANCE, builder.get_dc_local_read_repair_chance())); + } + if (has_property(KW_GCGRACESECONDS)) { builder.set_gc_grace_seconds(get_int(KW_GCGRACESECONDS, builder.get_gc_grace_seconds())); } diff --git a/db/legacy_schema_tables.cc b/db/legacy_schema_tables.cc index f31f23b615..670b5adb8f 100644 --- a/db/legacy_schema_tables.cc +++ b/db/legacy_schema_tables.cc @@ -1031,8 +1031,8 @@ future<> save_system_keyspace_schema() { m.set_clustered_cell(ckey, "default_validator", table->default_validator()->name(), timestamp); m.set_clustered_cell(ckey, "gc_grace_seconds", table->gc_grace_seconds(), timestamp); m.set_clustered_cell(ckey, "key_validator", table->thrift_key_validator(), timestamp); + m.set_clustered_cell(ckey, "local_read_repair_chance", table->dc_local_read_repair_chance(), timestamp); #if 0 - adder.add("local_read_repair_chance", table.getDcLocalReadRepairChance()); adder.add("max_compaction_threshold", table.getMaxCompactionThreshold()); adder.add("max_index_interval", table.getMaxIndexInterval()); adder.add("memtable_flush_period_in_ms", table.getMemtableFlushPeriod()); @@ -1260,8 +1260,11 @@ future<> save_system_keyspace_schema() { #if 0 cfm.readRepairChance(result.getDouble("read_repair_chance")); - cfm.dcLocalReadRepairChance(result.getDouble("local_read_repair_chance")); #endif + if (table_row.has("local_read_repair_chance")) { + builder.set_dc_local_read_repair_chance(table_row.get_nonnull("local_read_repair_chance")); + } + if (table_row.has("gc_grace_seconds")) { builder.set_gc_grace_seconds(table_row.get_nonnull("gc_grace_seconds")); } diff --git a/schema.hh b/schema.hh index 97a49618aa..6a27a82552 100644 --- a/schema.hh +++ b/schema.hh @@ -174,6 +174,7 @@ private: bool _is_dense = false; cf_type _type = cf_type::standard; int32_t _gc_grace_seconds = 864000; + double _dc_local_read_repair_chance = 0.1; }; raw_schema _raw; thrift_schema _thrift; @@ -273,6 +274,10 @@ public: return _raw._gc_grace_seconds; } + double dc_local_read_repair_chance() const { + return _raw._dc_local_read_repair_chance; + } + const column_definition* get_column_definition(const bytes& name) const; const_iterator regular_begin() const { return regular_columns().begin(); diff --git a/schema_builder.hh b/schema_builder.hh index 568289a824..0c33fd8d76 100644 --- a/schema_builder.hh +++ b/schema_builder.hh @@ -60,6 +60,14 @@ public: return _raw._gc_grace_seconds; } + void set_dc_local_read_repair_chance(double chance) { + _raw._dc_local_read_repair_chance = chance; + } + + double get_dc_local_read_repair_chance() { + return _raw._dc_local_read_repair_chance; + } + void set_bloom_filter_fp_chance(double fp) { _raw._bloom_filter_fp_chance = fp; } From aa270a149f4ea3edf59c1521c1093c50dbe85318 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Wed, 8 Jul 2015 16:26:00 -0400 Subject: [PATCH 4/6] schema: compaction strategy Signed-off-by: Glauber Costa --- cql3/statements/cf_prop_defs.hh | 28 ++++++++++++++++++++++------ db/legacy_schema_tables.cc | 14 ++++++++++---- schema.hh | 10 ++++++++++ schema_builder.hh | 16 ++++++++++++++++ 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/cql3/statements/cf_prop_defs.hh b/cql3/statements/cf_prop_defs.hh index d62cf9ef64..e3998f9159 100644 --- a/cql3/statements/cf_prop_defs.hh +++ b/cql3/statements/cf_prop_defs.hh @@ -175,13 +175,29 @@ public: if (has_property(KW_GCGRACESECONDS)) { builder.set_gc_grace_seconds(get_int(KW_GCGRACESECONDS, builder.get_gc_grace_seconds())); } + + std::experimental::optional tmp_value = {}; + if (has_property(KW_MINCOMPACTIONTHRESHOLD)) { + if (get_compaction_options().count(KW_MINCOMPACTIONTHRESHOLD)) { + tmp_value = get_compaction_options().at(KW_MINCOMPACTIONTHRESHOLD); + } + } + int min_compaction_threshold = to_int(KW_MINCOMPACTIONTHRESHOLD, tmp_value, builder.get_min_compaction_threshold()); + + tmp_value = {}; + if (has_property(KW_MAXCOMPACTIONTHRESHOLD)) { + if (get_compaction_options().count(KW_MAXCOMPACTIONTHRESHOLD)) { + tmp_value = get_compaction_options().at(KW_MAXCOMPACTIONTHRESHOLD); + } + } + int max_compaction_threshold = to_int(KW_MAXCOMPACTIONTHRESHOLD, tmp_value, builder.get_max_compaction_threshold()); + + if (min_compaction_threshold <= 0 || max_compaction_threshold <= 0) + throw exceptions::configuration_exception("Disabling compaction by setting compaction thresholds to 0 has been deprecated, set the compaction option 'enabled' to false instead."); + builder.set_min_compaction_threshold(min_compaction_threshold); + builder.set_max_compaction_threshold(max_compaction_threshold); + #if 0 - int minCompactionThreshold = toInt(KW_MINCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MINCOMPACTIONTHRESHOLD), cfm.getMinCompactionThreshold()); - int maxCompactionThreshold = toInt(KW_MAXCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MAXCOMPACTIONTHRESHOLD), cfm.getMaxCompactionThreshold()); - if (minCompactionThreshold <= 0 || maxCompactionThreshold <= 0) - throw new ConfigurationException("Disabling compaction by setting compaction thresholds to 0 has been deprecated, set the compaction option 'enabled' to false instead."); - cfm.minCompactionThreshold(minCompactionThreshold); - cfm.maxCompactionThreshold(maxCompactionThreshold); cfm.defaultTimeToLive(getInt(KW_DEFAULT_TIME_TO_LIVE, cfm.getDefaultTimeToLive())); cfm.speculativeRetry(CFMetaData.SpeculativeRetry.fromString(getString(KW_SPECULATIVE_RETRY, cfm.getSpeculativeRetry().toString()))); cfm.memtableFlushPeriod(getInt(KW_MEMTABLE_FLUSH_PERIOD, cfm.getMemtableFlushPeriod())); diff --git a/db/legacy_schema_tables.cc b/db/legacy_schema_tables.cc index 670b5adb8f..892561e78a 100644 --- a/db/legacy_schema_tables.cc +++ b/db/legacy_schema_tables.cc @@ -1032,11 +1032,11 @@ future<> save_system_keyspace_schema() { m.set_clustered_cell(ckey, "gc_grace_seconds", table->gc_grace_seconds(), timestamp); m.set_clustered_cell(ckey, "key_validator", table->thrift_key_validator(), timestamp); m.set_clustered_cell(ckey, "local_read_repair_chance", table->dc_local_read_repair_chance(), timestamp); + m.set_clustered_cell(ckey, "min_compaction_threshold", table->min_compaction_threshold(), timestamp); + m.set_clustered_cell(ckey, "max_compaction_threshold", table->max_compaction_threshold(), timestamp); #if 0 - adder.add("max_compaction_threshold", table.getMaxCompactionThreshold()); adder.add("max_index_interval", table.getMaxIndexInterval()); adder.add("memtable_flush_period_in_ms", table.getMemtableFlushPeriod()); - adder.add("min_compaction_threshold", table.getMinCompactionThreshold()); adder.add("min_index_interval", table.getMinIndexInterval()); adder.add("read_repair_chance", table.getReadRepairChance()); adder.add("speculative_retry", table.getSpeculativeRetry().toString()); @@ -1273,9 +1273,15 @@ future<> save_system_keyspace_schema() { builder.set_default_validator(parse_type(table_row.get_nonnull("default_validator"))); } + if (table_row.has("min_compaction_threshold")) { + builder.set_min_compaction_threshold(table_row.get_nonnull("min_compaction_threshold")); + } + + if (table_row.has("max_compaction_threshold")) { + builder.set_max_compaction_threshold(table_row.get_nonnull("max_compaction_threshold")); + } + #if 0 - cfm.minCompactionThreshold(result.getInt("min_compaction_threshold")); - cfm.maxCompactionThreshold(result.getInt("max_compaction_threshold")); if (result.has("comment")) cfm.comment(result.getString("comment")); if (result.has("memtable_flush_period_in_ms")) diff --git a/schema.hh b/schema.hh index 6a27a82552..014489b600 100644 --- a/schema.hh +++ b/schema.hh @@ -175,6 +175,8 @@ private: cf_type _type = cf_type::standard; int32_t _gc_grace_seconds = 864000; double _dc_local_read_repair_chance = 0.1; + int32_t _min_compaction_threshold = 4; + int32_t _max_compaction_threshold = 32; }; raw_schema _raw; thrift_schema _thrift; @@ -278,6 +280,14 @@ public: return _raw._dc_local_read_repair_chance; } + int32_t min_compaction_threshold() const { + return _raw._min_compaction_threshold; + } + + int32_t max_compaction_threshold() const { + return _raw._max_compaction_threshold; + } + const column_definition* get_column_definition(const bytes& name) const; const_iterator regular_begin() const { return regular_columns().begin(); diff --git a/schema_builder.hh b/schema_builder.hh index 0c33fd8d76..372464e643 100644 --- a/schema_builder.hh +++ b/schema_builder.hh @@ -68,6 +68,22 @@ public: return _raw._dc_local_read_repair_chance; } + void set_min_compaction_threshold(int32_t t) { + _raw._min_compaction_threshold = t; + } + + int32_t get_min_compaction_threshold() { + return _raw._min_compaction_threshold; + } + + void set_max_compaction_threshold(int32_t t) { + _raw._max_compaction_threshold = t; + } + + int32_t get_max_compaction_threshold() { + return _raw._max_compaction_threshold; + } + void set_bloom_filter_fp_chance(double fp) { _raw._bloom_filter_fp_chance = fp; } From ea17f6d76f8b5624c75ddc03b66fe42d1ed9e590 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Wed, 8 Jul 2015 16:45:25 -0400 Subject: [PATCH 5/6] schema: max and min index interval Signed-off-by: Glauber Costa --- cql3/statements/cf_prop_defs.hh | 11 +++++++++-- db/legacy_schema_tables.cc | 18 ++++++++++-------- schema.hh | 10 ++++++++++ schema_builder.hh | 16 ++++++++++++++++ 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/cql3/statements/cf_prop_defs.hh b/cql3/statements/cf_prop_defs.hh index e3998f9159..7f20b73867 100644 --- a/cql3/statements/cf_prop_defs.hh +++ b/cql3/statements/cf_prop_defs.hh @@ -201,9 +201,16 @@ public: cfm.defaultTimeToLive(getInt(KW_DEFAULT_TIME_TO_LIVE, cfm.getDefaultTimeToLive())); cfm.speculativeRetry(CFMetaData.SpeculativeRetry.fromString(getString(KW_SPECULATIVE_RETRY, cfm.getSpeculativeRetry().toString()))); cfm.memtableFlushPeriod(getInt(KW_MEMTABLE_FLUSH_PERIOD, cfm.getMemtableFlushPeriod())); - cfm.minIndexInterval(getInt(KW_MIN_INDEX_INTERVAL, cfm.getMinIndexInterval())); - cfm.maxIndexInterval(getInt(KW_MAX_INDEX_INTERVAL, cfm.getMaxIndexInterval())); +#endif + if (has_property(KW_MIN_INDEX_INTERVAL)) { + builder.set_min_index_interval(get_int(KW_MIN_INDEX_INTERVAL, builder.get_min_index_interval())); + } + if (has_property(KW_MAX_INDEX_INTERVAL)) { + builder.set_max_index_interval(get_int(KW_MAX_INDEX_INTERVAL, builder.get_max_index_interval())); + } + +#if 0 if (compactionStrategyClass != null) { cfm.compactionStrategyClass(compactionStrategyClass); diff --git a/db/legacy_schema_tables.cc b/db/legacy_schema_tables.cc index 892561e78a..76130cbd86 100644 --- a/db/legacy_schema_tables.cc +++ b/db/legacy_schema_tables.cc @@ -1034,10 +1034,10 @@ future<> save_system_keyspace_schema() { m.set_clustered_cell(ckey, "local_read_repair_chance", table->dc_local_read_repair_chance(), timestamp); m.set_clustered_cell(ckey, "min_compaction_threshold", table->min_compaction_threshold(), timestamp); m.set_clustered_cell(ckey, "max_compaction_threshold", table->max_compaction_threshold(), timestamp); + m.set_clustered_cell(ckey, "min_index_interval", table->min_index_interval(), timestamp); + m.set_clustered_cell(ckey, "max_index_interval", table->max_index_interval(), timestamp); #if 0 - adder.add("max_index_interval", table.getMaxIndexInterval()); adder.add("memtable_flush_period_in_ms", table.getMemtableFlushPeriod()); - adder.add("min_index_interval", table.getMinIndexInterval()); adder.add("read_repair_chance", table.getReadRepairChance()); adder.add("speculative_retry", table.getSpeculativeRetry().toString()); @@ -1298,14 +1298,16 @@ future<> save_system_keyspace_schema() { builder.set_compressor_params(cp); #if 0 cfm.compactionStrategyOptions(fromJsonMap(result.getString("compaction_strategy_options"))); - - if (result.has("min_index_interval")) - cfm.minIndexInterval(result.getInt("min_index_interval")); - - if (result.has("max_index_interval")) - cfm.maxIndexInterval(result.getInt("max_index_interval")); #endif + if (table_row.has("min_index_interval")) { + builder.set_min_index_interval(table_row.get_nonnull("min_index_interval")); + } + + if (table_row.has("max_index_interval")) { + builder.set_max_index_interval(table_row.get_nonnull("max_index_interval")); + } + if (table_row.has("bloom_filter_fp_chance")) { builder.set_bloom_filter_fp_chance(table_row.get_nonnull("bloom_filter_fp_chance")); } else { diff --git a/schema.hh b/schema.hh index 014489b600..a251756d52 100644 --- a/schema.hh +++ b/schema.hh @@ -177,6 +177,8 @@ private: double _dc_local_read_repair_chance = 0.1; int32_t _min_compaction_threshold = 4; int32_t _max_compaction_threshold = 32; + int32_t _min_index_interval = 128; + int32_t _max_index_interval = 2048; }; raw_schema _raw; thrift_schema _thrift; @@ -288,6 +290,14 @@ public: return _raw._max_compaction_threshold; } + int32_t min_index_interval() const { + return _raw._min_index_interval; + } + + int32_t max_index_interval() const { + return _raw._max_index_interval; + } + const column_definition* get_column_definition(const bytes& name) const; const_iterator regular_begin() const { return regular_columns().begin(); diff --git a/schema_builder.hh b/schema_builder.hh index 372464e643..9fe8c1dd59 100644 --- a/schema_builder.hh +++ b/schema_builder.hh @@ -84,6 +84,22 @@ public: return _raw._max_compaction_threshold; } + void set_min_index_interval(int32_t t) { + _raw._min_index_interval = t; + } + + int32_t get_min_index_interval() { + return _raw._min_index_interval; + } + + void set_max_index_interval(int32_t t) { + _raw._max_index_interval = t; + } + + int32_t get_max_index_interval() { + return _raw._max_index_interval; + } + void set_bloom_filter_fp_chance(double fp) { _raw._bloom_filter_fp_chance = fp; } From fe370ec84815b210a29ee07c4c22cc99f4df440f Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Thu, 9 Jul 2015 18:22:45 -0400 Subject: [PATCH 6/6] schema: read_repair_chance Signed-off-by: Glauber Costa --- cql3/statements/cf_prop_defs.hh | 8 +++++--- db/legacy_schema_tables.cc | 11 +++++++---- schema.hh | 5 +++++ schema_builder.hh | 8 ++++++++ 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/cql3/statements/cf_prop_defs.hh b/cql3/statements/cf_prop_defs.hh index 7f20b73867..4be276fbfe 100644 --- a/cql3/statements/cf_prop_defs.hh +++ b/cql3/statements/cf_prop_defs.hh @@ -165,9 +165,11 @@ public: if (has_property(KW_COMMENT)) { builder.set_comment(get_string(KW_COMMENT, "")); } -#if 0 - cfm.readRepairChance(getDouble(KW_READREPAIRCHANCE, cfm.getReadRepairChance())); -#endif + + if (has_property(KW_READREPAIRCHANCE)) { + builder.set_read_repair_chance(get_double(KW_READREPAIRCHANCE, builder.get_read_repair_chance())); + } + if (has_property(KW_DCLOCALREADREPAIRCHANCE)) { builder.set_dc_local_read_repair_chance(get_double(KW_DCLOCALREADREPAIRCHANCE, builder.get_dc_local_read_repair_chance())); } diff --git a/db/legacy_schema_tables.cc b/db/legacy_schema_tables.cc index 76130cbd86..0a82e9a1a2 100644 --- a/db/legacy_schema_tables.cc +++ b/db/legacy_schema_tables.cc @@ -1038,7 +1038,9 @@ future<> save_system_keyspace_schema() { m.set_clustered_cell(ckey, "max_index_interval", table->max_index_interval(), timestamp); #if 0 adder.add("memtable_flush_period_in_ms", table.getMemtableFlushPeriod()); - adder.add("read_repair_chance", table.getReadRepairChance()); +#endif + m.set_clustered_cell(ckey, "read_repair_chance", table->read_repair_chance(), timestamp); +#if 0 adder.add("speculative_retry", table.getSpeculativeRetry().toString()); for (Map.Entry entry : table.getDroppedColumns().entrySet()) @@ -1258,9 +1260,10 @@ future<> save_system_keyspace_schema() { #endif builder.set_is_dense(is_dense); -#if 0 - cfm.readRepairChance(result.getDouble("read_repair_chance")); -#endif + if (table_row.has("read_repair_chance")) { + builder.set_read_repair_chance(table_row.get_nonnull("read_repair_chance")); + } + if (table_row.has("local_read_repair_chance")) { builder.set_dc_local_read_repair_chance(table_row.get_nonnull("local_read_repair_chance")); } diff --git a/schema.hh b/schema.hh index a251756d52..23fe65b915 100644 --- a/schema.hh +++ b/schema.hh @@ -175,6 +175,7 @@ private: cf_type _type = cf_type::standard; 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_index_interval = 128; @@ -282,6 +283,10 @@ public: return _raw._dc_local_read_repair_chance; } + double read_repair_chance() const { + return _raw._read_repair_chance; + } + int32_t min_compaction_threshold() const { return _raw._min_compaction_threshold; } diff --git a/schema_builder.hh b/schema_builder.hh index 9fe8c1dd59..ac3b2953b8 100644 --- a/schema_builder.hh +++ b/schema_builder.hh @@ -68,6 +68,14 @@ public: return _raw._dc_local_read_repair_chance; } + void set_read_repair_chance(double chance) { + _raw._read_repair_chance = chance; + } + + double get_read_repair_chance() { + return _raw._read_repair_chance; + } + void set_min_compaction_threshold(int32_t t) { _raw._min_compaction_threshold = t; }