From bc23ebcbc3ca8b4257e7ca220f0bbdffa761c3c0 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Wed, 2 Dec 2015 10:22:45 +0100 Subject: [PATCH] schema_tables: Replace schema_result::value_type with equivalent movable type future<> requires and will assert nothrow move constructible types. --- database.cc | 6 +++--- db/schema_tables.cc | 16 ++++++++-------- db/schema_tables.hh | 7 ++++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/database.cc b/database.cc index 6426cf882b..4db79daab7 100644 --- a/database.cc +++ b/database.cc @@ -1032,7 +1032,7 @@ template static future<> do_parse_system_tables(distributed& proxy, const sstring& _cf_name, Func&& func) { using namespace db::schema_tables; - static_assert(std::is_same, std::result_of_t>::value, + static_assert(std::is_same, std::result_of_t>::value, "bad Func signature"); @@ -1067,11 +1067,11 @@ do_parse_system_tables(distributed& proxy, const sstring future<> database::parse_system_tables(distributed& proxy) { using namespace db::schema_tables; - return do_parse_system_tables(proxy, db::schema_tables::KEYSPACES, [this] (schema_result::value_type &v) { + return do_parse_system_tables(proxy, db::schema_tables::KEYSPACES, [this] (schema_result_value_type &v) { auto ksm = create_keyspace_from_schema_partition(v); return create_keyspace(ksm); }).then([&proxy, this] { - return do_parse_system_tables(proxy, db::schema_tables::COLUMNFAMILIES, [this, &proxy] (schema_result::value_type &v) { + return do_parse_system_tables(proxy, db::schema_tables::COLUMNFAMILIES, [this, &proxy] (schema_result_value_type &v) { return create_tables_from_tables_partition(proxy, v.second).then([this] (std::map tables) { for (auto& t: tables) { auto s = t.second; diff --git a/db/schema_tables.cc b/db/schema_tables.cc index b8b6d89d32..792f33c506 100644 --- a/db/schema_tables.cc +++ b/db/schema_tables.cc @@ -398,18 +398,18 @@ read_schema_for_keyspaces(distributed& proxy, const sstr return map_reduce(keyspace_names.begin(), keyspace_names.end(), map, schema_result{}, insert); } -future +future read_schema_partition_for_keyspace(distributed& proxy, const sstring& schema_table_name, const sstring& keyspace_name) { auto schema = proxy.local().get_db().local().find_schema(system_keyspace::NAME, schema_table_name); auto keyspace_key = dht::global_partitioner().decorate_key(*schema, partition_key::from_singular(*schema, keyspace_name)); return db::system_keyspace::query(proxy, schema_table_name, keyspace_key).then([keyspace_name] (auto&& rs) { - return schema_result::value_type{keyspace_name, std::move(rs)}; + return schema_result_value_type{keyspace_name, std::move(rs)}; }); } -future +future read_schema_partition_for_table(distributed& proxy, const sstring& schema_table_name, const sstring& keyspace_name, const sstring& table_name) { auto schema = proxy.local().get_db().local().find_schema(system_keyspace::NAME, schema_table_name); @@ -417,7 +417,7 @@ read_schema_partition_for_table(distributed& proxy, cons partition_key::from_singular(*schema, keyspace_name)); auto clustering_range = query::clustering_range(clustering_key_prefix::from_clustering_prefix(*schema, exploded_clustering_prefix({utf8_type->decompose(table_name)}))); return db::system_keyspace::query(proxy, schema_table_name, keyspace_key, clustering_range).then([keyspace_name] (auto&& rs) { - return schema_result::value_type{keyspace_name, std::move(rs)}; + return schema_result_value_type{keyspace_name, std::move(rs)}; }); } @@ -528,7 +528,7 @@ future<> do_merge_schema(distributed& proxy, std::vector future> merge_keyspaces(distributed& proxy, schema_result&& before, schema_result&& after) { - std::vector created; + std::vector created; std::vector altered; std::set dropped; @@ -552,7 +552,7 @@ future> merge_keyspaces(distributed& p for (auto&& key : diff.entries_only_on_right) { auto&& value = after[key]; if (!value->empty()) { - created.emplace_back(schema_result::value_type{key, std::move(value)}); + created.emplace_back(schema_result_value_type{key, std::move(value)}); } } for (auto&& key : diff.entries_differing) { @@ -566,7 +566,7 @@ future> merge_keyspaces(distributed& p } else if (!pre->empty()) { dropped.emplace(keyspace_name); } else if (!post->empty()) { // a (re)created keyspace - created.emplace_back(schema_result::value_type{key, std::move(post)}); + created.emplace_back(schema_result_value_type{key, std::move(post)}); } } return do_with(std::move(created), [&proxy, altered = std::move(altered)] (auto& created) { @@ -899,7 +899,7 @@ std::vector make_drop_keyspace_mutations(lw_shared_ptr create_keyspace_from_schema_partition(const schema_result::value_type& result) +lw_shared_ptr create_keyspace_from_schema_partition(const schema_result_value_type& result) { auto&& rs = result.second; if (rs->empty()) { diff --git a/db/schema_tables.hh b/db/schema_tables.hh index e1485f582d..0c47f03220 100644 --- a/db/schema_tables.hh +++ b/db/schema_tables.hh @@ -55,6 +55,7 @@ namespace db { namespace schema_tables { using schema_result = std::map>; +using schema_result_value_type = std::pair>; static constexpr auto KEYSPACES = "schema_keyspaces"; static constexpr auto COLUMNFAMILIES = "schema_columnfamilies"; @@ -74,7 +75,7 @@ future calculate_schema_digest(distributed& future> convert_schema_to_mutations(distributed& proxy); -future +future read_schema_partition_for_keyspace(distributed& proxy, const sstring& schema_table_name, const sstring& keyspace_name); future<> merge_schema(distributed& proxy, std::vector mutations); @@ -89,11 +90,11 @@ std::vector make_create_keyspace_mutations(lw_shared_ptr make_drop_keyspace_mutations(lw_shared_ptr keyspace, api::timestamp_type timestamp); -lw_shared_ptr create_keyspace_from_schema_partition(const schema_result::value_type& partition); +lw_shared_ptr create_keyspace_from_schema_partition(const schema_result_value_type& partition); future<> merge_tables(distributed& proxy, schema_result&& before, schema_result&& after); -lw_shared_ptr create_keyspace_from_schema_partition(const schema_result::value_type& partition); +lw_shared_ptr create_keyspace_from_schema_partition(const schema_result_value_type& partition); mutation make_create_keyspace_mutation(lw_shared_ptr keyspace, api::timestamp_type timestamp, bool with_tables_and_types_and_functions = true);