From 8b68fb5ff6c8b29785f0806086c16cee5f6ffd25 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 17 Jul 2015 20:23:57 -0400 Subject: [PATCH] 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; }