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 <glommer@cloudius-systems.com>
This commit is contained in:
Glauber Costa
2015-07-17 20:23:57 -04:00
parent 4d6457ba18
commit 8b68fb5ff6
3 changed files with 55 additions and 31 deletions

View File

@@ -58,7 +58,8 @@ using days = std::chrono::duration<int, std::ratio<24 * 3600>>;
#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<int, std::ratio<24 * 3600>>;
// 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<std::chrono::seconds>(days(7)).count());
)));
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(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<int, std::ratio<24 * 3600>>;
utf8_type,
// comment
"table definitions"
));
columnfamilies->set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
)));
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(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<int, std::ratio<24 * 3600>>;
utf8_type,
// comment
"column definitions"
));
columns->set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
)));
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(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<int, std::ratio<24 * 3600>>;
utf8_type,
// comment
"trigger definitions"
));
triggers->set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
)));
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(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<int, std::ratio<24 * 3600>>;
utf8_type,
// comment
"user defined type definitions"
));
usertypes->set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
)));
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(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<int, std::ratio<24 * 3600>>;
utf8_type,
// comment
"user defined type definitions"
));
functions->set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
)));
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(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<int, std::ratio<24 * 3600>>;
utf8_type,
// comment
"user defined aggregate definitions"
));
aggregates->set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
)));
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
return builder.build();
}();
return aggregates;
}

View File

@@ -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<int, std::ratio<24 * 3600>>;
@@ -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;
}

View File

@@ -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;
}