From d3e539e868bc052bd67a01ddb17c10f652168888 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 17 Jul 2015 19:36:16 -0400 Subject: [PATCH 1/6] schema: delete set_bloom_filter_fp_chance We do this through the builder now, and there are no more callers to this one. Signed-off-by: Glauber Costa --- schema.hh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/schema.hh b/schema.hh index e959eabc42..12011456f3 100644 --- a/schema.hh +++ b/schema.hh @@ -230,10 +230,6 @@ public: double bloom_filter_fp_chance() const { return _raw._bloom_filter_fp_chance; } - schema& set_bloom_filter_fp_chance(double fp) { - _raw._bloom_filter_fp_chance = fp; - return *this; - } sstring thrift_key_validator() const; void set_compressor_params(compression_parameters c) { _raw._compressor_params = c; From 75ffcefd9036bb3b6c4daed9824c1d577e9cc7e5 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 17 Jul 2015 19:46:38 -0400 Subject: [PATCH 2/6] schema: remove set_compressor_params use the builder instead. Sole current user is patched Signed-off-by: Glauber Costa --- schema.hh | 3 --- tests/urchin/sstable_datafile_test.cc | 7 ++++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/schema.hh b/schema.hh index 12011456f3..0fca912167 100644 --- a/schema.hh +++ b/schema.hh @@ -231,9 +231,6 @@ public: return _raw._bloom_filter_fp_chance; } sstring thrift_key_validator() const; - void set_compressor_params(compression_parameters c) { - _raw._compressor_params = c; - } const compression_parameters& get_compressor_params() const { return _raw._compressor_params; } diff --git a/tests/urchin/sstable_datafile_test.cc b/tests/urchin/sstable_datafile_test.cc index bf99258e06..b84c19ee63 100644 --- a/tests/urchin/sstable_datafile_test.cc +++ b/tests/urchin/sstable_datafile_test.cc @@ -11,6 +11,7 @@ #include "sstables/compaction.hh" #include "tests/test-utils.hh" #include "schema.hh" +#include "schema_builder.hh" #include "database.hh" #include #include "sstable_test.hh" @@ -883,10 +884,10 @@ SEASTAR_TEST_CASE(datafile_generation_12) { static future<> sstable_compression_test(compressor c, unsigned generation) { return test_setup::do_with_test_directory([c, generation] { - auto& cs = *complex_schema(); - auto s = make_lw_shared(schema(cs)); // NOTE: set a given compressor algorithm to schema. - s->set_compressor_params(c); + schema_builder builder(complex_schema()); + builder.set_compressor_params(c); + auto s = builder.build(); auto mtp = make_lw_shared(s); From 2d1561d4d2e72963326fe923c605dc2e2987cc97 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 17 Jul 2015 20:00:09 -0400 Subject: [PATCH 3/6] schema: remove set_id Pass it through the builder. Existing caller is patched. Signed-off-by: Glauber Costa --- schema.hh | 3 --- tests/urchin/cql_test_env.cc | 6 ++++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/schema.hh b/schema.hh index 0fca912167..88bac434fc 100644 --- a/schema.hh +++ b/schema.hh @@ -252,9 +252,6 @@ public: void set_comment(const sstring& comment) { _raw._comment = comment; } - void set_id(utils::UUID new_id) { - _raw._id = new_id; - } bool is_counter() const { return false; } diff --git a/tests/urchin/cql_test_env.cc b/tests/urchin/cql_test_env.cc index b8666d8139..b235c99aec 100644 --- a/tests/urchin/cql_test_env.cc +++ b/tests/urchin/cql_test_env.cc @@ -12,6 +12,7 @@ #include "message/messaging_service.hh" #include "service/storage_service.hh" #include "db/config.hh" +#include "schema_builder.hh" class in_memory_cql_env : public cql_test_env { public: @@ -93,8 +94,9 @@ public: virtual future<> create_table(std::function schema_maker) override { auto id = utils::UUID_gen::get_time_UUID(); return _db->invoke_on_all([schema_maker, id, this] (database& db) { - auto cf_schema = make_lw_shared(schema_maker(ks_name)); - cf_schema->set_id(id); + schema_builder builder(make_lw_shared(schema_maker(ks_name))); + builder.set_uuid(id); + auto cf_schema = builder.build(); auto& ks = db.find_keyspace(ks_name); auto cfg = ks.make_column_family_config(*cf_schema); db.add_column_family(std::move(cf_schema), std::move(cfg)); From 4d6457ba185397e136520f031822178785c8f1dc Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 17 Jul 2015 20:01:09 -0400 Subject: [PATCH 4/6] schema: remove set_comment There are no more callers left, all already happens through the builder. Signed-off-by: Glauber Costa --- schema.hh | 3 --- 1 file changed, 3 deletions(-) diff --git a/schema.hh b/schema.hh index 88bac434fc..3268fd3ba0 100644 --- a/schema.hh +++ b/schema.hh @@ -249,9 +249,6 @@ public: const sstring& comment() const { return _raw._comment; } - void set_comment(const sstring& comment) { - _raw._comment = comment; - } bool is_counter() const { return false; } From 8b68fb5ff6c8b29785f0806086c16cee5f6ffd25 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 17 Jul 2015 20:23:57 -0400 Subject: [PATCH 5/6] schema: remove set_gc_grace_period Make all callers go through the builder. Current callers - there are many in the system tables code, are patched. Signed-off-by: Glauber Costa --- db/legacy_schema_tables.cc | 63 +++++++++++++++++++++++++------------- db/system_keyspace.cc | 19 ++++++++---- schema.hh | 4 --- 3 files changed, 55 insertions(+), 31 deletions(-) diff --git a/db/legacy_schema_tables.cc b/db/legacy_schema_tables.cc index 87ca9fe448..1f1ecacbe8 100644 --- a/db/legacy_schema_tables.cc +++ b/db/legacy_schema_tables.cc @@ -58,7 +58,8 @@ using days = std::chrono::duration>; #endif /* static */ schema_ptr keyspaces() { - static thread_local auto keyspaces = make_lw_shared(schema(generate_legacy_id(NAME, KEYSPACES), NAME, KEYSPACES, + static thread_local auto keyspaces = [] { + schema_builder builder(make_lw_shared(schema(generate_legacy_id(NAME, KEYSPACES), NAME, KEYSPACES, // partition key {{"keyspace_name", utf8_type}}, // clustering key @@ -78,13 +79,16 @@ using days = std::chrono::duration>; // FIXME: the original Java code also had: // in CQL statement creating the table: // "WITH COMPACT STORAGE" - )); - keyspaces->set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + ))); + builder.set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + return builder.build(); + }(); return keyspaces; } /* static */ schema_ptr columnfamilies() { - static thread_local auto columnfamilies = make_lw_shared(schema(generate_legacy_id(NAME, COLUMNFAMILIES), NAME, COLUMNFAMILIES, + static thread_local auto columnfamilies = [] { + schema_builder builder(make_lw_shared(schema(generate_legacy_id(NAME, COLUMNFAMILIES), NAME, COLUMNFAMILIES, // partition key {{"keyspace_name", utf8_type}}, // clustering key @@ -122,13 +126,16 @@ using days = std::chrono::duration>; utf8_type, // comment "table definitions" - )); - columnfamilies->set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + ))); + builder.set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + return builder.build(); + }(); return columnfamilies; } /* static */ schema_ptr columns() { - static thread_local auto columns = make_lw_shared(schema(generate_legacy_id(NAME, COLUMNS), NAME, COLUMNS, + static thread_local auto columns = [] { + schema_builder builder(make_lw_shared(schema(generate_legacy_id(NAME, COLUMNS), NAME, COLUMNS, // partition key {{"keyspace_name", utf8_type}}, // clustering key @@ -148,13 +155,16 @@ using days = std::chrono::duration>; utf8_type, // comment "column definitions" - )); - columns->set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + ))); + builder.set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + return builder.build(); + }(); return columns; } /* static */ schema_ptr triggers() { - static thread_local auto triggers = make_lw_shared(schema(generate_legacy_id(NAME, TRIGGERS), NAME, TRIGGERS, + static thread_local auto triggers = [] { + schema_builder builder(make_lw_shared(schema(generate_legacy_id(NAME, TRIGGERS), NAME, TRIGGERS, // partition key {{"keyspace_name", utf8_type}}, // clustering key @@ -169,13 +179,16 @@ using days = std::chrono::duration>; utf8_type, // comment "trigger definitions" - )); - triggers->set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + ))); + builder.set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + return builder.build(); + }(); return triggers; } /* static */ schema_ptr usertypes() { - static thread_local auto usertypes = make_lw_shared(schema(generate_legacy_id(NAME, USERTYPES), NAME, USERTYPES, + static thread_local auto usertypes = [] { + schema_builder builder(make_lw_shared(schema(generate_legacy_id(NAME, USERTYPES), NAME, USERTYPES, // partition key {{"keyspace_name", utf8_type}}, // clustering key @@ -191,13 +204,16 @@ using days = std::chrono::duration>; utf8_type, // comment "user defined type definitions" - )); - usertypes->set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + ))); + builder.set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + return builder.build(); + }(); return usertypes; } /* static */ schema_ptr functions() { - static thread_local auto functions = make_lw_shared(schema(generate_legacy_id(NAME, FUNCTIONS), NAME, FUNCTIONS, + static thread_local auto functions = [] { + schema_builder builder(make_lw_shared(schema(generate_legacy_id(NAME, FUNCTIONS), NAME, FUNCTIONS, // partition key {{"keyspace_name", utf8_type}}, // clustering key @@ -217,13 +233,16 @@ using days = std::chrono::duration>; utf8_type, // comment "user defined type definitions" - )); - functions->set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + ))); + builder.set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + return builder.build(); + }(); return functions; } /* static */ schema_ptr aggregates() { - static thread_local auto aggregates = make_lw_shared(schema(generate_legacy_id(NAME, AGGREGATES), NAME, AGGREGATES, + static thread_local auto aggregates = [] { + schema_builder builder(make_lw_shared(schema(generate_legacy_id(NAME, AGGREGATES), NAME, AGGREGATES, // partition key {{"keyspace_name", utf8_type}}, // clustering key @@ -243,8 +262,10 @@ using days = std::chrono::duration>; utf8_type, // comment "user defined aggregate definitions" - )); - aggregates->set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + ))); + builder.set_gc_grace_seconds(std::chrono::duration_cast(days(7)).count()); + return builder.build(); + }(); return aggregates; } diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index ad7ca74a46..a81b33994a 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -42,6 +42,7 @@ #include "query_context.hh" #include "partition_slice_builder.hh" #include "db/config.hh" +#include "schema_builder.hh" using days = std::chrono::duration>; @@ -62,7 +63,8 @@ namespace system_keyspace { // functions will solve this problem. So we use functions right now. schema_ptr hints() { - static thread_local auto hints = make_lw_shared(schema(generate_legacy_id(NAME, HINTS), NAME, HINTS, + static thread_local auto hints = [] { + schema_builder builder(make_lw_shared(schema(generate_legacy_id(NAME, HINTS), NAME, HINTS, // partition key {{"target_id", uuid_type}}, // clustering key @@ -80,13 +82,16 @@ schema_ptr hints() { // "WITH COMPACT STORAGE" // operations on resulting CFMetaData: // .compactionStrategyOptions(Collections.singletonMap("enabled", "false")) - )); - hints->set_gc_grace_seconds(0); + ))); + builder.set_gc_grace_seconds(0); + return builder.build(); + }(); return hints; } schema_ptr batchlog() { - static thread_local auto batchlog = make_lw_shared(schema(generate_legacy_id(NAME, BATCHLOG), NAME, BATCHLOG, + static thread_local auto batchlog = [] { + schema_builder builder(make_lw_shared(schema(generate_legacy_id(NAME, BATCHLOG), NAME, BATCHLOG, // partition key {{"id", uuid_type}}, // clustering key @@ -102,8 +107,10 @@ schema_ptr batchlog() { // FIXME: the original Java code also had: // operations on resulting CFMetaData: // .compactionStrategyOptions(Collections.singletonMap("min_threshold", "2")) - )); - batchlog->set_gc_grace_seconds(0); + ))); + builder.set_gc_grace_seconds(0); + return builder.build(); + }(); return batchlog; } diff --git a/schema.hh b/schema.hh index 3268fd3ba0..fdac6d55e1 100644 --- a/schema.hh +++ b/schema.hh @@ -265,10 +265,6 @@ public: return _raw._gc_grace_seconds; } - void set_gc_grace_seconds(int32_t gc) { - _raw._gc_grace_seconds = gc; - } - double dc_local_read_repair_chance() const { return _raw._dc_local_read_repair_chance; } From 443178ef81b1098290137d0cc6f3897911996547 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 17 Jul 2015 20:27:12 -0400 Subject: [PATCH 6/6] schema: remove set_default_time_to_live Make calls go through the builder. Current caller is patched. Signed-off-by: Glauber Costa --- db/system_keyspace.cc | 9 ++++++--- schema.hh | 4 ---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index a81b33994a..36288317c6 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -277,7 +277,8 @@ schema_ptr built_indexes() { } /*static*/ schema_ptr compaction_history() { - static thread_local auto compaction_history = make_lw_shared(schema(generate_legacy_id(NAME, COMPACTION_HISTORY), NAME, COMPACTION_HISTORY, + static thread_local auto compaction_history = [] { + schema_builder builder(make_lw_shared(schema(generate_legacy_id(NAME, COMPACTION_HISTORY), NAME, COMPACTION_HISTORY, // partition key {{"id", uuid_type}}, // clustering key @@ -297,8 +298,10 @@ schema_ptr built_indexes() { utf8_type, // comment "week-long compaction history" - )); - compaction_history->set_default_time_to_live(std::chrono::duration_cast(days(7))); + ))); + builder.set_default_time_to_live(std::chrono::duration_cast(days(7))); + return builder.build(); + }(); return compaction_history; } diff --git a/schema.hh b/schema.hh index fdac6d55e1..091444399e 100644 --- a/schema.hh +++ b/schema.hh @@ -382,10 +382,6 @@ public: return _raw._default_time_to_live; } - void set_default_time_to_live(gc_clock::duration ttl) { - _raw._default_time_to_live = ttl; - } - const data_type& default_validator() const { return _raw._default_validator; }