Skip to content

Commit

Permalink
Swap arguments order of mutation constructor
Browse files Browse the repository at this point in the history
Swap arguments in the mutation constructor keeping the same standard
from the constructor variants. Refs #3084

Signed-off-by: José Guilherme Vanz <guilherme.sft@gmail.com>
Message-Id: <20180120000154.3823-1-guilherme.sft@gmail.com>
  • Loading branch information
José Guilherme Vanz authored and avikivity committed Jan 21, 2018
1 parent 20179c4 commit 380bc0a
Show file tree
Hide file tree
Showing 43 changed files with 297 additions and 297 deletions.
2 changes: 1 addition & 1 deletion canonical_mutation.cc
Expand Up @@ -75,7 +75,7 @@ mutation canonical_mutation::to_mutation(schema_ptr s) const {
auto version = mv.schema_version();
auto pk = mv.key();

mutation m(std::move(pk), std::move(s));
mutation m(std::move(s), std::move(pk));

if (version == m.schema()->version()) {
auto partition_view = mutation_partition_view::from_view(mv.partition());
Expand Down
2 changes: 1 addition & 1 deletion cql3/statements/modification_statement.cc
Expand Up @@ -159,7 +159,7 @@ modification_statement::get_mutations(distributed<service::storage_proxy>& proxy
mutations.reserve(keys->size());
for (auto key : *keys) {
// We know key.start() must be defined since we only allow EQ relations on the partition key.
mutations.emplace_back(std::move(*key.start()->value().key()), s);
mutations.emplace_back(s, std::move(*key.start()->value().key()));
auto& m = mutations.back();
for (auto&& r : *ranges) {
this->add_update_for_key(m, r, *params_ptr);
Expand Down
4 changes: 2 additions & 2 deletions db/batchlog_manager.cc
Expand Up @@ -162,7 +162,7 @@ mutation db::batchlog_manager::get_batch_log_mutation_for(const std::vector<muta
return to_bytes(out.linearize());
}();

mutation m(key, schema);
mutation m(schema, key);
m.set_cell(clustering_key_prefix::make_empty(), to_bytes("version"), version, timestamp);
m.set_cell(clustering_key_prefix::make_empty(), to_bytes("written_at"), now, timestamp);
m.set_cell(clustering_key_prefix::make_empty(), to_bytes("data"), data_value(std::move(data)), timestamp);
Expand Down Expand Up @@ -285,7 +285,7 @@ future<> db::batchlog_manager::replay_all_failed_batches() {
// delete batch
auto schema = _qp.db().local().find_schema(system_keyspace::NAME, system_keyspace::BATCHLOG);
auto key = partition_key::from_singular(*schema, id);
mutation m(key, schema);
mutation m(schema, key);
auto now = service::client_state(service::client_state::internal_tag()).get_timestamp();
m.partition().apply_delete(*schema, clustering_key_prefix::make_empty(), tombstone(now, gc_clock::now()));
return _qp.proxy().local().mutate_locally(m);
Expand Down
2 changes: 1 addition & 1 deletion db/commitlog/commitlog_replayer.cc
Expand Up @@ -295,7 +295,7 @@ future<> db::commitlog_replayer::impl::process(stats* s, temporary_buffer<char>
cm_it = local_cm.emplace(fm.schema_version(), src_cm).first;
}
const column_mapping& cm = cm_it->second;
mutation m(fm.decorated_key(*cf.schema()), cf.schema());
mutation m(cf.schema(), fm.decorated_key(*cf.schema()));
converting_mutation_partition_applier v(cm, *cf.schema(), m.partition());
fm.partition().accept(cm, v);
cf.apply(std::move(m));
Expand Down
2 changes: 1 addition & 1 deletion db/hints/manager.cc
Expand Up @@ -371,7 +371,7 @@ mutation manager::end_point_hints_manager::sender::get_mutation(lw_shared_ptr<se
auto& cf = _db.find_column_family(fm.column_family_id());

if (cf.schema()->version() != fm.schema_version()) {
mutation m(fm.decorated_key(*cf.schema()), cf.schema());
mutation m(cf.schema(), fm.decorated_key(*cf.schema()));
converting_mutation_partition_applier v(cm, *cf.schema(), m.partition());
fm.partition().accept(cm, v);

Expand Down
44 changes: 22 additions & 22 deletions db/schema_tables.cc
Expand Up @@ -616,7 +616,7 @@ future<mutation> query_partition_mutation(service::storage_proxy& proxy,
.then([dk = std::move(dk), s](foreign_ptr<lw_shared_ptr<reconcilable_result>> res, cache_temperature hit_rate) {
auto&& partitions = res->partitions();
if (partitions.size() == 0) {
return mutation(std::move(dk), s);
return mutation(s, std::move(dk));
} else if (partitions.size() == 1) {
return partitions[0].mut().unfreeze(s);
} else {
Expand Down Expand Up @@ -1233,7 +1233,7 @@ std::vector<mutation> make_create_keyspace_mutations(lw_shared_ptr<keyspace_meta
std::vector<mutation> mutations;
schema_ptr s = keyspaces();
auto pkey = partition_key::from_singular(*s, keyspace->name());
mutation m(pkey, s);
mutation m(s, pkey);
auto ckey = clustering_key_prefix::make_empty();
m.set_cell(ckey, "durable_writes", keyspace->durable_writes(), timestamp);

Expand Down Expand Up @@ -1261,13 +1261,13 @@ std::vector<mutation> make_drop_keyspace_mutations(lw_shared_ptr<keyspace_metada
std::vector<mutation> mutations;
for (auto&& schema_table : all_tables()) {
auto pkey = partition_key::from_exploded(*schema_table, {utf8_type->decompose(keyspace->name())});
mutation m{pkey, schema_table};
mutation m{schema_table, pkey};
m.partition().apply(tombstone{timestamp, gc_clock::now()});
mutations.emplace_back(std::move(m));
}
auto&& schema = db::system_keyspace::built_indexes();
auto pkey = partition_key::from_exploded(*schema, {utf8_type->decompose(keyspace->name())});
mutation m{pkey, schema};
mutation m{schema, pkey};
m.partition().apply(tombstone{timestamp, gc_clock::now()});
mutations.emplace_back(std::move(m));
return mutations;
Expand Down Expand Up @@ -1379,7 +1379,7 @@ void add_type_to_schema_mutation(user_type type, api::timestamp_type timestamp,
schema_ptr s = types();
auto pkey = partition_key::from_singular(*s, type->_keyspace);
auto ckey = clustering_key::from_singular(*s, type->get_name_as_string());
mutation m{pkey, s};
mutation m{s, pkey};

auto field_names_column = s->get_column_definition("field_names");
auto field_names = make_list_mutation(type->field_names(), *field_names_column, timestamp, [](auto&& name) {
Expand Down Expand Up @@ -1411,7 +1411,7 @@ future<std::vector<mutation>> make_drop_type_mutations(lw_shared_ptr<keyspace_me
schema_ptr s = types();
auto pkey = partition_key::from_singular(*s, type->_keyspace);
auto ckey = clustering_key::from_singular(*s, type->get_name_as_string());
mutation m{pkey, s};
mutation m{s, pkey};
m.partition().apply_delete(*s, ckey, tombstone(timestamp, gc_clock::now()));
mutations.emplace_back(std::move(m));

Expand Down Expand Up @@ -1527,7 +1527,7 @@ mutation make_scylla_tables_mutation(schema_ptr table, api::timestamp_type times
schema_ptr s = tables();
auto pkey = partition_key::from_singular(*s, table->ks_name());
auto ckey = clustering_key::from_singular(*s, table->cf_name());
mutation m(pkey, scylla_tables());
mutation m(scylla_tables(), pkey);
m.set_clustered_cell(ckey, "version", utils::UUID(table->version()), timestamp);
return m;
}
Expand All @@ -1541,7 +1541,7 @@ static schema_mutations make_table_mutations(schema_ptr table, api::timestamp_ty
// we don't keep a property the user has removed
schema_ptr s = tables();
auto pkey = partition_key::from_singular(*s, table->ks_name());
mutation m{pkey, s};
mutation m{s, pkey};
auto ckey = clustering_key::from_singular(*s, table->cf_name());
m.set_clustered_cell(ckey, "id", table->id(), timestamp);

Expand All @@ -1567,9 +1567,9 @@ static schema_mutations make_table_mutations(schema_ptr table, api::timestamp_ty

add_table_params_to_mutations(m, ckey, table, timestamp);

mutation columns_mutation(pkey, columns());
mutation dropped_columns_mutation(pkey, dropped_columns());
mutation indices_mutation(pkey, indexes());
mutation columns_mutation(columns(), pkey);
mutation dropped_columns_mutation(dropped_columns(), pkey);
mutation indices_mutation(indexes(), pkey);

if (with_columns_and_triggers) {
for (auto&& column : table->v3().all_columns()) {
Expand Down Expand Up @@ -1603,7 +1603,7 @@ static void make_update_indices_mutations(
api::timestamp_type timestamp,
std::vector<mutation>& mutations)
{
mutation indices_mutation(partition_key::from_singular(*indexes(), old_table->ks_name()), indexes());
mutation indices_mutation(indexes(), partition_key::from_singular(*indexes(), old_table->ks_name()));

auto diff = difference(old_table->all_indices(), new_table->all_indices());

Expand Down Expand Up @@ -1633,7 +1633,7 @@ static void add_drop_column_to_mutations(schema_ptr table, const sstring& name,
schema_ptr s = dropped_columns();
auto pkey = partition_key::from_singular(*s, table->ks_name());
auto ckey = clustering_key::from_exploded(*s, {utf8_type->decompose(table->cf_name()), utf8_type->decompose(name)});
mutation m(pkey, s);
mutation m(s, pkey);
add_dropped_column_to_schema_mutation(table, name, dc, timestamp, m);
mutations.emplace_back(std::move(m));
}
Expand All @@ -1643,7 +1643,7 @@ static void make_update_columns_mutations(schema_ptr old_table,
api::timestamp_type timestamp,
bool from_thrift,
std::vector<mutation>& mutations) {
mutation columns_mutation(partition_key::from_singular(*columns(), old_table->ks_name()), columns());
mutation columns_mutation(columns(), partition_key::from_singular(*columns(), old_table->ks_name()));

auto diff = difference(old_table->v3().columns_by_name(), new_table->v3().columns_by_name());

Expand Down Expand Up @@ -1710,7 +1710,7 @@ static void make_drop_table_or_view_mutations(schema_ptr schema_table,
api::timestamp_type timestamp,
std::vector<mutation>& mutations) {
auto pkey = partition_key::from_singular(*schema_table, table_or_view->ks_name());
mutation m{pkey, schema_table};
mutation m{schema_table, pkey};
auto ckey = clustering_key::from_singular(*schema_table, table_or_view->cf_name());
m.partition().apply_delete(*schema_table, ckey, tombstone(timestamp, gc_clock::now()));
mutations.emplace_back(m);
Expand All @@ -1721,7 +1721,7 @@ static void make_drop_table_or_view_mutations(schema_ptr schema_table,
drop_column_from_schema_mutation(dropped_columns(), table_or_view, column, timestamp, mutations);
}
{
mutation m{pkey, scylla_tables()};
mutation m{scylla_tables(), pkey};
m.partition().apply_delete(*scylla_tables(), ckey, tombstone(timestamp, gc_clock::now()));
mutations.emplace_back(m);
}
Expand Down Expand Up @@ -2086,7 +2086,7 @@ static void drop_index_from_schema_mutation(schema_ptr table, const index_metada
schema_ptr s = indexes();
auto pkey = partition_key::from_singular(*s, table->ks_name());
auto ckey = clustering_key::from_exploded(*s, {utf8_type->decompose(table->cf_name()), utf8_type->decompose(index.name())});
mutation m{pkey, s};
mutation m{s, pkey};
m.partition().apply_delete(*s, ckey, tombstone(timestamp, gc_clock::now()));
mutations.push_back(std::move(m));
}
Expand All @@ -2102,7 +2102,7 @@ static void drop_column_from_schema_mutation(
auto ckey = clustering_key::from_exploded(*schema_table, {utf8_type->decompose(table->cf_name()),
utf8_type->decompose(column_name)});

mutation m{pkey, schema_table};
mutation m{schema_table, pkey};
m.partition().apply_delete(*schema_table, ckey, tombstone(timestamp, gc_clock::now()));
mutations.emplace_back(m);
}
Expand Down Expand Up @@ -2230,7 +2230,7 @@ static schema_mutations make_view_mutations(view_ptr view, api::timestamp_type t
// we don't keep a property the user has removed
schema_ptr s = views();
auto pkey = partition_key::from_singular(*s, view->ks_name());
mutation m{pkey, s};
mutation m{s, pkey};
auto ckey = clustering_key::from_singular(*s, view->cf_name());

m.set_clustered_cell(ckey, "base_table_id", view->view_info()->base_id(), timestamp);
Expand All @@ -2243,9 +2243,9 @@ static schema_mutations make_view_mutations(view_ptr view, api::timestamp_type t
add_table_params_to_mutations(m, ckey, view, timestamp);


mutation columns_mutation(pkey, columns());
mutation dropped_columns_mutation(pkey, dropped_columns());
mutation indices_mutation(pkey, indexes());
mutation columns_mutation(columns(), pkey);
mutation dropped_columns_mutation(dropped_columns(), pkey);
mutation indices_mutation(indexes(), pkey);

if (with_columns) {
for (auto&& column : view->v3().all_columns()) {
Expand Down
2 changes: 1 addition & 1 deletion db/system_keyspace.cc
Expand Up @@ -1769,7 +1769,7 @@ future<int> increment_and_get_generation() {
mutation make_size_estimates_mutation(const sstring& ks, std::vector<range_estimates> estimates) {
auto&& schema = db::system_keyspace::size_estimates();
auto timestamp = api::new_timestamp();
mutation m_to_apply{partition_key::from_single_value(*schema, utf8_type->decompose(ks)), schema};
mutation m_to_apply{schema, partition_key::from_single_value(*schema, utf8_type->decompose(ks))};

for (auto&& e : estimates) {
auto ck = clustering_key_prefix(std::vector<bytes>{
Expand Down
2 changes: 1 addition & 1 deletion frozen_mutation.cc
Expand Up @@ -107,7 +107,7 @@ frozen_mutation::frozen_mutation(const mutation& m)

mutation
frozen_mutation::unfreeze(schema_ptr schema) const {
mutation m(key(*schema), schema);
mutation m(schema, key(*schema));
partition_builder b(*schema, m.partition());
partition().accept(*schema, b);
return m;
Expand Down
4 changes: 2 additions & 2 deletions mutation.hh
Expand Up @@ -50,10 +50,10 @@ private:
explicit operator bool() const { return bool(_ptr); }
friend class optimized_optional<mutation>;
public:
mutation(dht::decorated_key key, schema_ptr schema)
mutation(schema_ptr schema, dht::decorated_key key)
: _ptr(std::make_unique<data>(std::move(key), std::move(schema)))
{ }
mutation(partition_key key_, schema_ptr schema)
mutation(schema_ptr schema, partition_key key_)
: _ptr(std::make_unique<data>(std::move(key_), std::move(schema)))
{ }
mutation(schema_ptr schema, dht::decorated_key key, const mutation_partition& mp)
Expand Down
2 changes: 1 addition & 1 deletion mutation_partition.cc
Expand Up @@ -1969,7 +1969,7 @@ class counter_write_query_result_builder {
public:
counter_write_query_result_builder(const schema& s) : _schema(s) { }
void consume_new_partition(const dht::decorated_key& dk) {
_mutation = mutation(dk, _schema.shared_from_this());
_mutation = mutation(_schema.shared_from_this(), dk);
}
void consume(tombstone) { }
stop_iteration consume(static_row&& sr, tombstone, bool) {
Expand Down
4 changes: 2 additions & 2 deletions mutation_rebuilder.hh
Expand Up @@ -29,7 +29,7 @@ class mutation_rebuilder {

public:
mutation_rebuilder(dht::decorated_key dk, schema_ptr s)
: _m(std::move(dk), std::move(s)), _remaining_limit(0) {
: _m(std::move(s), std::move(dk)), _remaining_limit(0) {
}

stop_iteration consume(tombstone t) {
Expand Down Expand Up @@ -58,4 +58,4 @@ public:
mutation_opt consume_end_of_stream() {
return mutation_opt(std::move(_m));
}
};
};
4 changes: 2 additions & 2 deletions service/storage_proxy.cc
Expand Up @@ -1491,7 +1491,7 @@ storage_proxy::mutate_atomically(std::vector<mutation> mutations, db::consistenc
auto schema = _p._db.local().find_schema(db::system_keyspace::NAME, db::system_keyspace::BATCHLOG);
auto key = partition_key::from_exploded(*schema, {uuid_type->decompose(_batch_uuid)});
auto now = service::client_state(service::client_state::internal_tag()).get_timestamp();
mutation m(key, schema);
mutation m(schema, key);
m.partition().apply_delete(*schema, clustering_key_prefix::make_empty(), tombstone(now, gc_clock::now()));

tracing::trace(_trace_state, "Sending a batchlog remove mutation");
Expand Down Expand Up @@ -2369,7 +2369,7 @@ class data_read_resolver : public abstract_read_resolver {
auto it = boost::range::find_if(v, [] (auto&& ver) {
return bool(ver.par);
});
auto m = boost::accumulate(v, mutation(it->par->mut().key(*schema), schema), [this, schema] (mutation& m, const version& ver) {
auto m = boost::accumulate(v, mutation(schema, it->par->mut().key(*schema)), [this, schema] (mutation& m, const version& ver) {
if (ver.par) {
m.partition().apply(*schema, ver.par->mut().partition(), *schema);
}
Expand Down
2 changes: 1 addition & 1 deletion streamed_mutation.cc
Expand Up @@ -218,7 +218,7 @@ std::ostream& operator<<(std::ostream& os, const mutation_fragment& mf) {
}

streamed_mutation make_empty_streamed_mutation(schema_ptr s, dht::decorated_key key, streamed_mutation::forwarding fwd) {
return streamed_mutation_from_mutation(mutation(std::move(key), std::move(s)), fwd);
return streamed_mutation_from_mutation(mutation(std::move(s), std::move(key)), fwd);
}

streamed_mutation streamed_mutation_from_mutation(mutation m, streamed_mutation::forwarding fwd)
Expand Down
2 changes: 1 addition & 1 deletion tests/batchlog_manager_test.cc
Expand Up @@ -56,7 +56,7 @@ SEASTAR_TEST_CASE(test_execute_batch) {
auto key = partition_key::from_exploded(*s, {to_bytes("key1")});
auto c_key = clustering_key::from_exploded(*s, {int32_type->decompose(1)});

mutation m(key, s);
mutation m(s, key);
m.set_clustered_cell(c_key, r1_col, make_atomic_cell(int32_type->decompose(100)));

using namespace std::chrono_literals;
Expand Down
14 changes: 7 additions & 7 deletions tests/cache_flat_mutation_reader_test.cc
Expand Up @@ -249,7 +249,7 @@ void test_single_row(int ck,
std::deque<expected_row> expected_cache_rows) {
const int value = 12;

mutation underlying(PK, SCHEMA);
mutation underlying(SCHEMA, PK);
add_row(underlying, ck, value);

auto m = make_incomplete_mutation();
Expand Down Expand Up @@ -560,7 +560,7 @@ void test_two_rows(int ck1,
const int value1 = 12;
const int value2 = 34;

mutation underlying(PK, SCHEMA);
mutation underlying(SCHEMA, PK);
add_row(underlying, ck1, value1);
add_row(underlying, ck2, value2);

Expand Down Expand Up @@ -1140,7 +1140,7 @@ void test_three_rows(int ck1,
const int value2 = 34;
const int value3 = 56;

mutation underlying(PK, SCHEMA);
mutation underlying(SCHEMA, PK);
add_row(underlying, ck1, value1);
add_row(underlying, ck2, value2);
add_row(underlying, ck3, value3);
Expand Down Expand Up @@ -1283,7 +1283,7 @@ SEASTAR_TEST_CASE(test_single_row_and_tombstone_not_cached_single_row_range1) {
const int value1 = 12;
range_tombstone rt(make_ck(0), bound_kind::incl_start, make_ck(2), bound_kind::incl_end, new_tombstone());

mutation underlying(PK, SCHEMA);
mutation underlying(SCHEMA, PK);
add_row(underlying, ck1, value1);
add_tombstone(underlying, rt);

Expand All @@ -1306,7 +1306,7 @@ SEASTAR_TEST_CASE(test_single_row_and_tombstone_not_cached_single_row_range2) {
const int value1 = 12;
range_tombstone rt(make_ck(0), bound_kind::incl_start, make_ck(2), bound_kind::incl_end, new_tombstone());

mutation underlying(PK, SCHEMA);
mutation underlying(SCHEMA, PK);
add_row(underlying, ck1, value1);
add_tombstone(underlying, rt);

Expand All @@ -1329,7 +1329,7 @@ SEASTAR_TEST_CASE(test_single_row_and_tombstone_not_cached_single_row_range3) {
const int value1 = 12;
range_tombstone rt(make_ck(0), bound_kind::incl_start, make_ck(2), bound_kind::incl_end, new_tombstone());

mutation underlying(PK, SCHEMA);
mutation underlying(SCHEMA, PK);
add_row(underlying, ck1, value1);
add_tombstone(underlying, rt);

Expand All @@ -1354,7 +1354,7 @@ SEASTAR_TEST_CASE(test_single_row_and_tombstone_not_cached_single_row_range4) {
const int value1 = 12;
range_tombstone rt(make_ck(0), bound_kind::incl_start, make_ck(2), bound_kind::incl_end, new_tombstone());

mutation underlying(PK, SCHEMA);
mutation underlying(SCHEMA, PK);
add_row(underlying, ck1, value1);
add_tombstone(underlying, rt);

Expand Down
4 changes: 2 additions & 2 deletions tests/cell_locker_test.cc
Expand Up @@ -82,7 +82,7 @@ static auto make_row(const sstring& key, std::initializer_list<sstring> cells) {
static mutation make_mutation(schema_ptr s, const sstring& pk, std::initializer_list<sstring> static_cells,
std::initializer_list<std::pair<sstring, std::initializer_list<sstring>>> clustering_cells)
{
auto m = mutation(partition_key::from_single_value(*s, to_bytes(pk)), s);
auto m = mutation(s, partition_key::from_single_value(*s, to_bytes(pk)));
for (auto&& c : static_cells) {
m.set_static_cell(to_bytes(c), empty_value, api::new_timestamp());
}
Expand Down Expand Up @@ -132,7 +132,7 @@ SEASTAR_TEST_CASE(test_disjoint_mutations) {
make_row("one", { "r3" }),
});

auto m3 = mutation(partition_key::from_single_value(*s, to_bytes("1")), s);
auto m3 = mutation(s, partition_key::from_single_value(*s, to_bytes("1")));
m3.partition() = m1.partition();

auto l1 = cl.lock_cells(m1.decorated_key(), partition_cells_range(m1.partition()), no_timeout).get0();
Expand Down

0 comments on commit 380bc0a

Please sign in to comment.