schema_builder: provide a build function that doesn't take compact storage.
We will invoke the schema builder from schema_tables.cc, and at that point, the information about compact storage no longer exists anywhere. If we just call it like this, it will be the same as calling it with compact_storage::no, which will trigger a (wrong) recomputation for compact_storage::yes CFs The best way to solve that, is make the compact_storage parameter mandatory every time we create a new table - instead of defaulting to no. This will ensure that the correct dense and compound calculation are always done when calling the builder with a parameter, and not done at all when we call it without a parameter. Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
This commit is contained in:
@@ -130,7 +130,7 @@ using days = std::chrono::duration<int, std::ratio<24 * 3600>>;
|
||||
"table definitions"
|
||||
)));
|
||||
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return columnfamilies;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ using days = std::chrono::duration<int, std::ratio<24 * 3600>>;
|
||||
"column definitions"
|
||||
)));
|
||||
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return columns;
|
||||
}
|
||||
@@ -183,7 +183,7 @@ using days = std::chrono::duration<int, std::ratio<24 * 3600>>;
|
||||
"trigger definitions"
|
||||
)));
|
||||
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return triggers;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ using days = std::chrono::duration<int, std::ratio<24 * 3600>>;
|
||||
"user defined type definitions"
|
||||
)));
|
||||
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return usertypes;
|
||||
}
|
||||
@@ -237,7 +237,7 @@ using days = std::chrono::duration<int, std::ratio<24 * 3600>>;
|
||||
"user defined type definitions"
|
||||
)));
|
||||
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return functions;
|
||||
}
|
||||
@@ -266,7 +266,7 @@ using days = std::chrono::duration<int, std::ratio<24 * 3600>>;
|
||||
"user defined aggregate definitions"
|
||||
)));
|
||||
builder.set_gc_grace_seconds(std::chrono::duration_cast<std::chrono::seconds>(days(7)).count());
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return aggregates;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ schema_ptr batchlog() {
|
||||
// .compactionStrategyOptions(Collections.singletonMap("min_threshold", "2"))
|
||||
)));
|
||||
builder.set_gc_grace_seconds(0);
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return batchlog;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ schema_ptr batchlog() {
|
||||
// operations on resulting CFMetaData:
|
||||
// .compactionStrategyClass(LeveledCompactionStrategy.class);
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return paxos;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ schema_ptr built_indexes() {
|
||||
// comment
|
||||
"information about the local node"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return local;
|
||||
}
|
||||
@@ -221,7 +221,7 @@ schema_ptr built_indexes() {
|
||||
// comment
|
||||
"information about known peers in the cluster"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return peers;
|
||||
}
|
||||
@@ -244,7 +244,7 @@ schema_ptr built_indexes() {
|
||||
// comment
|
||||
"events related to peers"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return peer_events;
|
||||
}
|
||||
@@ -265,7 +265,7 @@ schema_ptr built_indexes() {
|
||||
// comment
|
||||
"ranges requested for transfer"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return range_xfers;
|
||||
}
|
||||
@@ -290,7 +290,7 @@ schema_ptr built_indexes() {
|
||||
// comment
|
||||
"unfinished compactions"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return compactions_in_progress;
|
||||
}
|
||||
@@ -319,7 +319,7 @@ schema_ptr built_indexes() {
|
||||
"week-long compaction history"
|
||||
)));
|
||||
builder.set_default_time_to_live(std::chrono::duration_cast<std::chrono::seconds>(days(7)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return compaction_history;
|
||||
}
|
||||
@@ -347,7 +347,7 @@ schema_ptr built_indexes() {
|
||||
// comment
|
||||
"historic sstable read rates"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return sstable_activity;
|
||||
}
|
||||
@@ -372,7 +372,7 @@ schema_ptr size_estimates() {
|
||||
"per-table primary range size estimates"
|
||||
)));
|
||||
builder.set_gc_grace_seconds(0);
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return size_estimates;
|
||||
}
|
||||
|
||||
@@ -336,6 +336,10 @@ schema_builder& schema_builder::with_column(bytes name, data_type type, index_in
|
||||
return *this;
|
||||
}
|
||||
|
||||
schema_ptr schema_builder::build() {
|
||||
return make_lw_shared<schema>(schema(_raw));
|
||||
}
|
||||
|
||||
schema_ptr schema_builder::build(compact_storage cp) {
|
||||
schema s(_raw);
|
||||
|
||||
|
||||
@@ -163,5 +163,6 @@ public:
|
||||
void add_default_index_names(database&);
|
||||
|
||||
enum class compact_storage { no, yes };
|
||||
schema_ptr build(compact_storage = compact_storage::no);
|
||||
schema_ptr build(compact_storage cp);
|
||||
schema_ptr build();
|
||||
};
|
||||
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
return _db->invoke_on_all([schema_maker, id, this] (database& db) {
|
||||
schema_builder builder(make_lw_shared(schema_maker(ks_name)));
|
||||
builder.set_uuid(id);
|
||||
auto cf_schema = builder.build();
|
||||
auto cf_schema = builder.build(schema_builder::compact_storage::no);
|
||||
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));
|
||||
|
||||
@@ -900,7 +900,7 @@ static future<> sstable_compression_test(compressor c, unsigned generation) {
|
||||
// NOTE: set a given compressor algorithm to schema.
|
||||
schema_builder builder(complex_schema());
|
||||
builder.set_compressor_params(c);
|
||||
auto s = builder.build();
|
||||
auto s = builder.build(schema_builder::compact_storage::no);
|
||||
|
||||
auto mtp = make_lw_shared<memtable>(s);
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ inline schema_ptr composite_schema() {
|
||||
// comment
|
||||
"Table with a composite key as pkey"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return s;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ inline schema_ptr set_schema() {
|
||||
// comment
|
||||
"Table with a set as pkeys"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return s;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ inline schema_ptr map_schema() {
|
||||
// comment
|
||||
"Table with a map as pkeys"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return s;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ inline schema_ptr list_schema() {
|
||||
// comment
|
||||
"Table with a list as pkeys"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return s;
|
||||
}
|
||||
@@ -196,7 +196,7 @@ inline schema_ptr uncompressed_schema() {
|
||||
// comment
|
||||
"Uncompressed data"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return uncompressed;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ inline schema_ptr complex_schema() {
|
||||
// comment
|
||||
"Table with a complex schema, including collections and static keys"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return s;
|
||||
}
|
||||
@@ -257,7 +257,7 @@ inline schema_ptr columns_schema() {
|
||||
// comment
|
||||
"column definitions"
|
||||
)));
|
||||
return builder.build();
|
||||
return builder.build(schema_builder::compact_storage::no);
|
||||
}();
|
||||
return columns;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user