mutation: Set cell using clustering_key_prefix
Change the clustering key argument in mutation::set_cell from exploded_clustering_prefix to clustering_key_prefix, which allows for some overall code simplification and fewer copies. This mostly affects the cql3 layer. Signed-off-by: Duarte Nunes <duarte@scylladb.com>
This commit is contained in:
@@ -159,7 +159,7 @@ constants::literal::prepare(database& db, const sstring& keyspace, ::shared_ptr<
|
||||
return ::make_shared<value>(cql3::raw_value::make_value(parsed_value(receiver->type)));
|
||||
}
|
||||
|
||||
void constants::deleter::execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) {
|
||||
void constants::deleter::execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) {
|
||||
if (column.type->is_multi_cell()) {
|
||||
collection_type_impl::mutation coll_m;
|
||||
coll_m.tomb = params.make_tombstone();
|
||||
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
public:
|
||||
using operation::operation;
|
||||
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override {
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override {
|
||||
auto value = _t->bind_and_get(params._options);
|
||||
if (value.is_null()) {
|
||||
m.set_cell(prefix, column, std::move(make_dead_cell(params)));
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
struct adder final : operation {
|
||||
using operation::operation;
|
||||
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override {
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override {
|
||||
auto value = _t->bind_and_get(params._options);
|
||||
if (value.is_null()) {
|
||||
throw exceptions::invalid_request_exception("Invalid null value for counter increment");
|
||||
@@ -225,7 +225,7 @@ public:
|
||||
struct subtracter final : operation {
|
||||
using operation::operation;
|
||||
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override {
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override {
|
||||
auto value = _t->bind_and_get(params._options);
|
||||
if (value.is_null()) {
|
||||
throw exceptions::invalid_request_exception("Invalid null value for counter increment");
|
||||
@@ -246,7 +246,7 @@ public:
|
||||
: operation(column, {})
|
||||
{ }
|
||||
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ lists::precision_time::get_next(db_clock::time_point millis) {
|
||||
}
|
||||
|
||||
void
|
||||
lists::setter::execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) {
|
||||
lists::setter::execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) {
|
||||
const auto& value = _t->bind(params._options);
|
||||
if (value == constants::UNSET_VALUE) {
|
||||
return;
|
||||
@@ -270,15 +270,10 @@ lists::setter_by_index::collect_marker_specification(shared_ptr<variable_specifi
|
||||
}
|
||||
|
||||
void
|
||||
lists::setter_by_index::execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) {
|
||||
lists::setter_by_index::execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) {
|
||||
// we should not get here for frozen lists
|
||||
assert(column.type->is_multi_cell()); // "Attempted to set an individual element on a frozen list";
|
||||
|
||||
std::experimental::optional<clustering_key> row_key;
|
||||
if (!column.is_static()) {
|
||||
row_key = clustering_key::from_clustering_prefix(*params._schema, prefix);
|
||||
}
|
||||
|
||||
auto index = _idx->bind_and_get(params._options);
|
||||
if (index.is_null()) {
|
||||
throw exceptions::invalid_request_exception("Invalid null value for list index");
|
||||
@@ -292,7 +287,7 @@ lists::setter_by_index::execute(mutation& m, const exploded_clustering_prefix& p
|
||||
}
|
||||
|
||||
auto idx = net::ntoh(int32_t(*unaligned_cast<int32_t>(index->begin())));
|
||||
auto&& existing_list_opt = params.get_prefetched_list(m.key(), std::move(row_key), column);
|
||||
auto&& existing_list_opt = params.get_prefetched_list(m.key().view(), prefix.view(), column);
|
||||
if (!existing_list_opt) {
|
||||
throw exceptions::invalid_request_exception("Attempted to set an element on a list which is null");
|
||||
}
|
||||
@@ -327,15 +322,10 @@ lists::setter_by_uuid::requires_read() {
|
||||
}
|
||||
|
||||
void
|
||||
lists::setter_by_uuid::execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) {
|
||||
lists::setter_by_uuid::execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) {
|
||||
// we should not get here for frozen lists
|
||||
assert(column.type->is_multi_cell()); // "Attempted to set an individual element on a frozen list";
|
||||
|
||||
std::experimental::optional<clustering_key> row_key;
|
||||
if (!column.is_static()) {
|
||||
row_key = clustering_key::from_clustering_prefix(*params._schema, prefix);
|
||||
}
|
||||
|
||||
auto index = _idx->bind_and_get(params._options);
|
||||
auto value = _t->bind_and_get(params._options);
|
||||
|
||||
@@ -355,7 +345,7 @@ lists::setter_by_uuid::execute(mutation& m, const exploded_clustering_prefix& pr
|
||||
}
|
||||
|
||||
void
|
||||
lists::appender::execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) {
|
||||
lists::appender::execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) {
|
||||
const auto& value = _t->bind(params._options);
|
||||
if (value == constants::UNSET_VALUE) {
|
||||
return;
|
||||
@@ -367,7 +357,7 @@ lists::appender::execute(mutation& m, const exploded_clustering_prefix& prefix,
|
||||
void
|
||||
lists::do_append(shared_ptr<term> value,
|
||||
mutation& m,
|
||||
const exploded_clustering_prefix& prefix,
|
||||
const clustering_key_prefix& prefix,
|
||||
const column_definition& column,
|
||||
const update_parameters& params) {
|
||||
auto&& list_value = dynamic_pointer_cast<lists::value>(value);
|
||||
@@ -401,7 +391,7 @@ lists::do_append(shared_ptr<term> value,
|
||||
}
|
||||
|
||||
void
|
||||
lists::prepender::execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) {
|
||||
lists::prepender::execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) {
|
||||
assert(column.type->is_multi_cell()); // "Attempted to prepend to a frozen list";
|
||||
auto&& value = _t->bind(params._options);
|
||||
if (!value || value == constants::UNSET_VALUE) {
|
||||
@@ -433,15 +423,10 @@ lists::discarder::requires_read() {
|
||||
}
|
||||
|
||||
void
|
||||
lists::discarder::execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) {
|
||||
lists::discarder::execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) {
|
||||
assert(column.type->is_multi_cell()); // "Attempted to delete from a frozen list";
|
||||
|
||||
std::experimental::optional<clustering_key> row_key;
|
||||
if (!column.is_static()) {
|
||||
row_key = clustering_key::from_clustering_prefix(*params._schema, prefix);
|
||||
}
|
||||
|
||||
auto&& existing_list = params.get_prefetched_list(m.key(), std::move(row_key), column);
|
||||
auto&& existing_list = params.get_prefetched_list(m.key().view(), prefix.view(), column);
|
||||
// We want to call bind before possibly returning to reject queries where the value provided is not a list.
|
||||
auto&& value = _t->bind(params._options);
|
||||
|
||||
@@ -490,7 +475,7 @@ lists::discarder_by_index::requires_read() {
|
||||
}
|
||||
|
||||
void
|
||||
lists::discarder_by_index::execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) {
|
||||
lists::discarder_by_index::execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) {
|
||||
assert(column.type->is_multi_cell()); // "Attempted to delete an item by index from a frozen list";
|
||||
auto&& index = _t->bind(params._options);
|
||||
if (!index) {
|
||||
@@ -504,11 +489,7 @@ lists::discarder_by_index::execute(mutation& m, const exploded_clustering_prefix
|
||||
auto cvalue = dynamic_pointer_cast<constants::value>(index);
|
||||
assert(cvalue);
|
||||
|
||||
std::experimental::optional<clustering_key> row_key;
|
||||
if (!column.is_static()) {
|
||||
row_key = clustering_key::from_clustering_prefix(*params._schema, prefix);
|
||||
}
|
||||
auto&& existing_list_opt = params.get_prefetched_list(m.key(), std::move(row_key), column);
|
||||
auto&& existing_list_opt = params.get_prefetched_list(m.key().view(), prefix.view(), column);
|
||||
int32_t idx = read_simple_exactly<int32_t>(*cvalue->_bytes);
|
||||
if (!existing_list_opt) {
|
||||
throw exceptions::invalid_request_exception("Attempted to delete an element from a list which is null");
|
||||
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
setter(const column_definition& column, shared_ptr<term> t)
|
||||
: operation(column, std::move(t)) {
|
||||
}
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
|
||||
};
|
||||
|
||||
class setter_by_index : public operation {
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
}
|
||||
virtual bool requires_read() override;
|
||||
virtual void collect_marker_specification(shared_ptr<variable_specifications> bound_names);
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
|
||||
};
|
||||
|
||||
class setter_by_uuid : public setter_by_index {
|
||||
@@ -167,25 +167,25 @@ public:
|
||||
: setter_by_index(column, std::move(idx), std::move(t)) {
|
||||
}
|
||||
virtual bool requires_read() override;
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
|
||||
};
|
||||
|
||||
class appender : public operation {
|
||||
public:
|
||||
using operation::operation;
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
|
||||
};
|
||||
|
||||
static void do_append(shared_ptr<term> value,
|
||||
mutation& m,
|
||||
const exploded_clustering_prefix& prefix,
|
||||
const clustering_key_prefix& prefix,
|
||||
const column_definition& column,
|
||||
const update_parameters& params);
|
||||
|
||||
class prepender : public operation {
|
||||
public:
|
||||
using operation::operation;
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
|
||||
};
|
||||
|
||||
class discarder : public operation {
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
: operation(column, std::move(t)) {
|
||||
}
|
||||
virtual bool requires_read() override;
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
|
||||
};
|
||||
|
||||
class discarder_by_index : public operation {
|
||||
@@ -203,7 +203,7 @@ public:
|
||||
: operation(column, std::move(idx)) {
|
||||
}
|
||||
virtual bool requires_read() override;
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params);
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
10
cql3/maps.cc
10
cql3/maps.cc
@@ -269,7 +269,7 @@ maps::marker::bind(const query_options& options) {
|
||||
}
|
||||
|
||||
void
|
||||
maps::setter::execute(mutation& m, const exploded_clustering_prefix& row_key, const update_parameters& params) {
|
||||
maps::setter::execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params) {
|
||||
auto value = _t->bind(params._options);
|
||||
if (value == constants::UNSET_VALUE) {
|
||||
return;
|
||||
@@ -292,7 +292,7 @@ maps::setter_by_key::collect_marker_specification(shared_ptr<variable_specificat
|
||||
}
|
||||
|
||||
void
|
||||
maps::setter_by_key::execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) {
|
||||
maps::setter_by_key::execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) {
|
||||
using exceptions::invalid_request_exception;
|
||||
assert(column.type->is_multi_cell()); // "Attempted to set a value for a single key on a frozen map"m
|
||||
auto key = _k->bind_and_get(params._options);
|
||||
@@ -315,7 +315,7 @@ maps::setter_by_key::execute(mutation& m, const exploded_clustering_prefix& pref
|
||||
}
|
||||
|
||||
void
|
||||
maps::putter::execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) {
|
||||
maps::putter::execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) {
|
||||
assert(column.type->is_multi_cell()); // "Attempted to add items to a frozen map";
|
||||
auto value = _t->bind(params._options);
|
||||
if (value != constants::UNSET_VALUE) {
|
||||
@@ -324,7 +324,7 @@ maps::putter::execute(mutation& m, const exploded_clustering_prefix& prefix, con
|
||||
}
|
||||
|
||||
void
|
||||
maps::do_put(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params,
|
||||
maps::do_put(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params,
|
||||
shared_ptr<term> value, const column_definition& column) {
|
||||
auto map_value = dynamic_pointer_cast<maps::value>(value);
|
||||
if (column.type->is_multi_cell()) {
|
||||
@@ -353,7 +353,7 @@ maps::do_put(mutation& m, const exploded_clustering_prefix& prefix, const update
|
||||
}
|
||||
|
||||
void
|
||||
maps::discarder_by_key::execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) {
|
||||
maps::discarder_by_key::execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) {
|
||||
assert(column.type->is_multi_cell()); // "Attempted to delete a single key in a frozen map";
|
||||
auto&& key = _t->bind(params._options);
|
||||
if (!key) {
|
||||
|
||||
10
cql3/maps.hh
10
cql3/maps.hh
@@ -116,7 +116,7 @@ public:
|
||||
: operation(column, std::move(t)) {
|
||||
}
|
||||
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& row_key, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params) override;
|
||||
};
|
||||
|
||||
class setter_by_key : public operation {
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
: operation(column, std::move(t)), _k(std::move(k)) {
|
||||
}
|
||||
virtual void collect_marker_specification(shared_ptr<variable_specifications> bound_names) override;
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
|
||||
};
|
||||
|
||||
class putter : public operation {
|
||||
@@ -134,10 +134,10 @@ public:
|
||||
putter(const column_definition& column, shared_ptr<term> t)
|
||||
: operation(column, std::move(t)) {
|
||||
}
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
|
||||
};
|
||||
|
||||
static void do_put(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params,
|
||||
static void do_put(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params,
|
||||
shared_ptr<term> value, const column_definition& column);
|
||||
|
||||
class discarder_by_key : public operation {
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
discarder_by_key(const column_definition& column, shared_ptr<term> k)
|
||||
: operation(column, std::move(k)) {
|
||||
}
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ operation::set_counter_value_from_tuple_list::prepare(database& db, const sstrin
|
||||
bool is_raw_counter_shard_write() const override {
|
||||
return true;
|
||||
}
|
||||
void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override {
|
||||
void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override {
|
||||
const auto& value = _t->bind(params._options);
|
||||
auto&& list_value = dynamic_pointer_cast<lists::value>(value);
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
/**
|
||||
* Execute the operation.
|
||||
*/
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) = 0;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) = 0;
|
||||
|
||||
/**
|
||||
* A parsed raw UPDATE operation.
|
||||
|
||||
10
cql3/sets.cc
10
cql3/sets.cc
@@ -224,7 +224,7 @@ sets::marker::bind(const query_options& options) {
|
||||
}
|
||||
|
||||
void
|
||||
sets::setter::execute(mutation& m, const exploded_clustering_prefix& row_key, const update_parameters& params) {
|
||||
sets::setter::execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params) {
|
||||
const auto& value = _t->bind(params._options);
|
||||
if (value == constants::UNSET_VALUE) {
|
||||
return;
|
||||
@@ -241,7 +241,7 @@ sets::setter::execute(mutation& m, const exploded_clustering_prefix& row_key, co
|
||||
}
|
||||
|
||||
void
|
||||
sets::adder::execute(mutation& m, const exploded_clustering_prefix& row_key, const update_parameters& params) {
|
||||
sets::adder::execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params) {
|
||||
const auto& value = _t->bind(params._options);
|
||||
if (value == constants::UNSET_VALUE) {
|
||||
return;
|
||||
@@ -251,7 +251,7 @@ sets::adder::execute(mutation& m, const exploded_clustering_prefix& row_key, con
|
||||
}
|
||||
|
||||
void
|
||||
sets::adder::do_add(mutation& m, const exploded_clustering_prefix& row_key, const update_parameters& params,
|
||||
sets::adder::do_add(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params,
|
||||
shared_ptr<term> value, const column_definition& column) {
|
||||
auto set_value = dynamic_pointer_cast<sets::value>(std::move(value));
|
||||
auto set_type = dynamic_pointer_cast<const set_type_impl>(column.type);
|
||||
@@ -281,7 +281,7 @@ sets::adder::do_add(mutation& m, const exploded_clustering_prefix& row_key, cons
|
||||
}
|
||||
|
||||
void
|
||||
sets::discarder::execute(mutation& m, const exploded_clustering_prefix& row_key, const update_parameters& params) {
|
||||
sets::discarder::execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params) {
|
||||
assert(column.type->is_multi_cell()); // "Attempted to remove items from a frozen set";
|
||||
|
||||
auto&& value = _t->bind(params._options);
|
||||
@@ -305,7 +305,7 @@ sets::discarder::execute(mutation& m, const exploded_clustering_prefix& row_key,
|
||||
ctype->serialize_mutation_form(mut)));
|
||||
}
|
||||
|
||||
void sets::element_discarder::execute(mutation& m, const exploded_clustering_prefix& row_key, const update_parameters& params)
|
||||
void sets::element_discarder::execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params)
|
||||
{
|
||||
assert(column.type->is_multi_cell() && "Attempted to remove items from a frozen set");
|
||||
auto elt = _t->bind(params._options);
|
||||
|
||||
10
cql3/sets.hh
10
cql3/sets.hh
@@ -112,7 +112,7 @@ public:
|
||||
setter(const column_definition& column, shared_ptr<term> t)
|
||||
: operation(column, std::move(t)) {
|
||||
}
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& row_key, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params) override;
|
||||
};
|
||||
|
||||
class adder : public operation {
|
||||
@@ -120,8 +120,8 @@ public:
|
||||
adder(const column_definition& column, shared_ptr<term> t)
|
||||
: operation(column, std::move(t)) {
|
||||
}
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& row_key, const update_parameters& params) override;
|
||||
static void do_add(mutation& m, const exploded_clustering_prefix& row_key, const update_parameters& params,
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params) override;
|
||||
static void do_add(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params,
|
||||
shared_ptr<term> value, const column_definition& column);
|
||||
};
|
||||
|
||||
@@ -131,14 +131,14 @@ public:
|
||||
discarder(const column_definition& column, shared_ptr<term> t)
|
||||
: operation(column, std::move(t)) {
|
||||
}
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& row_key, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params) override;
|
||||
};
|
||||
|
||||
class element_discarder : public operation {
|
||||
public:
|
||||
element_discarder(const column_definition& column, shared_ptr<term> t)
|
||||
: operation(column, std::move(t)) { }
|
||||
virtual void execute(mutation& m, const exploded_clustering_prefix& row_key, const update_parameters& params) override;
|
||||
virtual void execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params) override;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ void delete_statement::add_update_for_key(mutation& m, const query::clustering_r
|
||||
if (s->clustering_key_size() == 0 || range.is_full()) {
|
||||
m.partition().apply(params.make_tombstone());
|
||||
} else if (range.is_singular()) {
|
||||
m.partition().apply_delete(*s, exploded_clustering_prefix(range.start()->value().explode()), params.make_tombstone());
|
||||
m.partition().apply_delete(*s, range.start()->value(), params.make_tombstone());
|
||||
} else {
|
||||
auto bvs = bound_view::from_range(range);
|
||||
m.partition().apply_delete(*s, range_tombstone(bvs.first, bvs.second, params.make_tombstone()));
|
||||
@@ -72,7 +72,7 @@ void delete_statement::add_update_for_key(mutation& m, const query::clustering_r
|
||||
}
|
||||
|
||||
for (auto&& op : _column_operations) {
|
||||
op->execute(m, range.start() ? exploded_clustering_prefix(range.start()->value().explode()) : exploded_clustering_prefix(), params);
|
||||
op->execute(m, range.start() ? std::move(range.start()->value()) : clustering_key_prefix::make_empty(), params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ public:
|
||||
add_cell(cells, _schema->static_column_at(id), static_row_iterator.next_collection_cell());
|
||||
}
|
||||
|
||||
_data.rows.emplace(std::make_pair(*_pkey, std::experimental::nullopt), std::move(cells));
|
||||
_data.rows.emplace(std::make_pair(*_pkey, clustering_key_prefix::make_empty()), std::move(cells));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -63,12 +63,11 @@ bool update_statement::allow_clustering_key_slices() const {
|
||||
}
|
||||
|
||||
void update_statement::add_update_for_key(mutation& m, const query::clustering_range& range, const update_parameters& params) {
|
||||
exploded_clustering_prefix prefix(range.start() ? range.start()->value().explode() : std::vector<bytes>());
|
||||
auto prefix = range.start() ? std::move(range.start()->value()) : clustering_key_prefix::make_empty();
|
||||
if (s->is_dense()) {
|
||||
if (!prefix || (prefix.size() == 1 && prefix.components().front().empty())) {
|
||||
if (prefix.is_empty(*s)) {
|
||||
throw exceptions::invalid_request_exception(sprint("Missing PRIMARY KEY part %s", s->clustering_key_columns().begin()->name_as_text()));
|
||||
}
|
||||
|
||||
// An empty name for the value is what we use to recognize the case where there is not column
|
||||
// outside the PK, see CreateStatement.
|
||||
if (s->regular_begin()->name().empty()) {
|
||||
@@ -84,9 +83,9 @@ void update_statement::add_update_for_key(mutation& m, const query::clustering_r
|
||||
} else {
|
||||
// If there are static columns, there also must be clustering columns, in which
|
||||
// case empty prefix can only refer to the static row.
|
||||
bool is_static_prefix = s->has_static_columns() && !prefix;
|
||||
bool is_static_prefix = s->has_static_columns() && prefix.is_empty(*s);
|
||||
if (type == statement_type::INSERT && !is_static_prefix && s->is_cql3_table()) {
|
||||
auto& row = m.partition().clustered_row(*s, clustering_key::from_clustering_prefix(*s, prefix));
|
||||
auto& row = m.partition().clustered_row(*s, prefix);
|
||||
row.apply(row_marker(params.timestamp(), params.ttl(), params.expiry()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace cql3 {
|
||||
|
||||
const update_parameters::prefetch_data::cell_list*
|
||||
update_parameters::get_prefetched_list(
|
||||
partition_key pkey,
|
||||
std::experimental::optional<clustering_key> ckey,
|
||||
partition_key_view pkey,
|
||||
clustering_key_view ckey,
|
||||
const column_definition& column) const
|
||||
{
|
||||
if (!_prefetched) {
|
||||
|
||||
@@ -60,7 +60,8 @@ class update_parameters final {
|
||||
public:
|
||||
// Holder for data needed by CQL list updates which depend on current state of the list.
|
||||
struct prefetch_data {
|
||||
using key = std::pair<partition_key, std::experimental::optional<clustering_key>>;
|
||||
using key = std::pair<partition_key, clustering_key>;
|
||||
using key_view = std::pair<partition_key_view, clustering_key_view>;
|
||||
struct key_hashing {
|
||||
partition_key::hashing pk_hash;
|
||||
clustering_key::hashing ck_hash;
|
||||
@@ -71,7 +72,11 @@ public:
|
||||
{ }
|
||||
|
||||
size_t operator()(const key& k) const {
|
||||
return pk_hash(k.first) ^ (k.second ? ck_hash(*k.second) : 0);
|
||||
return pk_hash(k.first) ^ ck_hash(k.second);
|
||||
}
|
||||
|
||||
size_t operator()(const key_view& k) const {
|
||||
return pk_hash(k.first) ^ ck_hash(k.second);
|
||||
}
|
||||
};
|
||||
struct key_equality {
|
||||
@@ -84,8 +89,13 @@ public:
|
||||
{ }
|
||||
|
||||
bool operator()(const key& k1, const key& k2) const {
|
||||
return pk_eq(k1.first, k2.first)
|
||||
&& bool(k1.second) == bool(k2.second) && (!k1.second || ck_eq(*k1.second, *k2.second));
|
||||
return pk_eq(k1.first, k2.first) && ck_eq(k1.second, k2.second);
|
||||
}
|
||||
bool operator()(const key_view& k1, const key& k2) const {
|
||||
return pk_eq(k1.first, k2.first) && ck_eq(k1.second, k2.second);
|
||||
}
|
||||
bool operator()(const key& k1, const key_view& k2) const {
|
||||
return pk_eq(k1.first, k2.first) && ck_eq(k1.second, k2.second);
|
||||
}
|
||||
};
|
||||
struct cell {
|
||||
@@ -188,8 +198,8 @@ public:
|
||||
|
||||
const prefetch_data::cell_list*
|
||||
get_prefetched_list(
|
||||
partition_key pkey,
|
||||
std::experimental::optional<clustering_key> ckey,
|
||||
partition_key_view pkey,
|
||||
clustering_key_view ckey,
|
||||
const column_definition& column) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -162,9 +162,9 @@ mutation db::batchlog_manager::get_batch_log_mutation_for(const std::vector<muta
|
||||
}();
|
||||
|
||||
mutation m(key, schema);
|
||||
m.set_cell({}, to_bytes("version"), version, timestamp);
|
||||
m.set_cell({}, to_bytes("written_at"), now, timestamp);
|
||||
m.set_cell({}, to_bytes("data"), data_value(std::move(data)), timestamp);
|
||||
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);
|
||||
|
||||
return m;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ future<> db::batchlog_manager::replay_all_failed_batches() {
|
||||
auto key = partition_key::from_singular(*schema, id);
|
||||
mutation m(key, schema);
|
||||
auto now = service::client_state(service::client_state::internal_tag()).get_timestamp();
|
||||
m.partition().apply_delete(*schema, {}, tombstone(now, gc_clock::now()));
|
||||
m.partition().apply_delete(*schema, clustering_key_prefix::make_empty(), tombstone(now, gc_clock::now()));
|
||||
return _qp.proxy().local().mutate_locally(m);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1082,11 +1082,10 @@ std::vector<mutation> make_create_keyspace_mutations(lw_shared_ptr<keyspace_meta
|
||||
schema_ptr s = keyspaces();
|
||||
auto pkey = partition_key::from_singular(*s, keyspace->name());
|
||||
mutation m(pkey, s);
|
||||
exploded_clustering_prefix ckey;
|
||||
m.set_cell(ckey, "durable_writes", keyspace->durable_writes(), timestamp);
|
||||
m.set_cell(ckey, "strategy_class", keyspace->strategy_name(), timestamp);
|
||||
m.set_cell(clustering_key_prefix::make_empty(), "durable_writes", keyspace->durable_writes(), timestamp);
|
||||
m.set_cell(clustering_key_prefix::make_empty(), "strategy_class", keyspace->strategy_name(), timestamp);
|
||||
auto raw = json::to_json(keyspace->strategy_options());
|
||||
m.set_cell(ckey, "strategy_options", raw, timestamp);
|
||||
m.set_cell(clustering_key_prefix::make_empty(), "strategy_options", raw, timestamp);
|
||||
mutations.emplace_back(std::move(m));
|
||||
|
||||
if (with_tables_and_types_and_functions) {
|
||||
|
||||
3
keys.hh
3
keys.hh
@@ -254,6 +254,9 @@ public:
|
||||
size_t operator()(const TopLevel& o) const {
|
||||
return _t->hash(o);
|
||||
}
|
||||
size_t operator()(const TopLevelView& o) const {
|
||||
return _t->hash(o.representation());
|
||||
}
|
||||
};
|
||||
|
||||
struct equality {
|
||||
|
||||
@@ -61,11 +61,6 @@ void mutation::set_static_cell(const bytes& name, const data_value& value, api::
|
||||
partition().static_row().apply(*column_def, atomic_cell::make_live(timestamp, column_def->type->decompose(value), ttl));
|
||||
}
|
||||
|
||||
void mutation::set_clustered_cell(const exploded_clustering_prefix& prefix, const column_definition& def, atomic_cell_or_collection&& value) {
|
||||
auto& row = partition().clustered_row(*schema(), clustering_key::from_clustering_prefix(*schema(), prefix)).cells();
|
||||
row.apply(def, std::move(value));
|
||||
}
|
||||
|
||||
void mutation::set_clustered_cell(const clustering_key& key, const bytes& name, const data_value& value,
|
||||
api::timestamp_type timestamp, ttl_opt ttl) {
|
||||
auto column_def = schema()->get_column_definition(name);
|
||||
@@ -80,7 +75,7 @@ void mutation::set_clustered_cell(const clustering_key& key, const column_defini
|
||||
row.apply(def, std::move(value));
|
||||
}
|
||||
|
||||
void mutation::set_cell(const exploded_clustering_prefix& prefix, const bytes& name, const data_value& value,
|
||||
void mutation::set_cell(const clustering_key_prefix& prefix, const bytes& name, const data_value& value,
|
||||
api::timestamp_type timestamp, ttl_opt ttl) {
|
||||
auto column_def = schema()->get_column_definition(name);
|
||||
if (!column_def) {
|
||||
@@ -89,7 +84,7 @@ void mutation::set_cell(const exploded_clustering_prefix& prefix, const bytes& n
|
||||
return set_cell(prefix, *column_def, atomic_cell::make_live(timestamp, column_def->type->decompose(value), ttl));
|
||||
}
|
||||
|
||||
void mutation::set_cell(const exploded_clustering_prefix& prefix, const column_definition& def, atomic_cell_or_collection&& value) {
|
||||
void mutation::set_cell(const clustering_key_prefix& prefix, const column_definition& def, atomic_cell_or_collection&& value) {
|
||||
if (def.is_static()) {
|
||||
set_static_cell(def, std::move(value));
|
||||
} else if (def.is_regular()) {
|
||||
|
||||
@@ -70,11 +70,10 @@ public:
|
||||
|
||||
void set_static_cell(const column_definition& def, atomic_cell_or_collection&& value);
|
||||
void set_static_cell(const bytes& name, const data_value& value, api::timestamp_type timestamp, ttl_opt ttl = {});
|
||||
void set_clustered_cell(const exploded_clustering_prefix& prefix, const column_definition& def, atomic_cell_or_collection&& value);
|
||||
void set_clustered_cell(const clustering_key& key, const bytes& name, const data_value& value, api::timestamp_type timestamp, ttl_opt ttl = {});
|
||||
void set_clustered_cell(const clustering_key& key, const column_definition& def, atomic_cell_or_collection&& value);
|
||||
void set_cell(const exploded_clustering_prefix& prefix, const bytes& name, const data_value& value, api::timestamp_type timestamp, ttl_opt ttl = {});
|
||||
void set_cell(const exploded_clustering_prefix& prefix, const column_definition& def, atomic_cell_or_collection&& value);
|
||||
void set_cell(const clustering_key_prefix& prefix, const bytes& name, const data_value& value, api::timestamp_type timestamp, ttl_opt ttl = {});
|
||||
void set_cell(const clustering_key_prefix& prefix, const column_definition& def, atomic_cell_or_collection&& value);
|
||||
|
||||
// Upgrades this mutation to a newer schema. The new schema must
|
||||
// be obtained using only valid schema transformation:
|
||||
|
||||
@@ -418,17 +418,6 @@ mutation_partition::apply_row_tombstone(const schema& schema, range_tombstone rt
|
||||
_row_tombstones.apply(schema, std::move(rt));
|
||||
}
|
||||
|
||||
void
|
||||
mutation_partition::apply_delete(const schema& schema, const exploded_clustering_prefix& prefix, tombstone t) {
|
||||
if (!prefix) {
|
||||
apply(t);
|
||||
} else if (prefix.is_full(schema)) {
|
||||
apply_delete(schema, clustering_key::from_clustering_prefix(schema, prefix), t);
|
||||
} else {
|
||||
apply_row_tombstone(schema, clustering_key_prefix::from_clustering_prefix(schema, prefix), t);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
mutation_partition::apply_delete(const schema& schema, const clustering_key_prefix& prefix, tombstone t) {
|
||||
if (prefix.is_empty(schema)) {
|
||||
|
||||
@@ -778,7 +778,6 @@ public:
|
||||
friend std::ostream& operator<<(std::ostream& os, const mutation_partition& mp);
|
||||
public:
|
||||
void apply(tombstone t) { _tombstone.apply(t); }
|
||||
void apply_delete(const schema& schema, const exploded_clustering_prefix& prefix, tombstone t);
|
||||
void apply_delete(const schema& schema, const clustering_key_prefix& prefix, tombstone t);
|
||||
void apply_delete(const schema& schema, range_tombstone rt);
|
||||
void apply_delete(const schema& schema, clustering_key_prefix&& prefix, tombstone t);
|
||||
|
||||
@@ -1405,7 +1405,7 @@ storage_proxy::mutate_atomically(std::vector<mutation> mutations, db::consistenc
|
||||
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);
|
||||
m.partition().apply_delete(*schema, {}, tombstone(now, gc_clock::now()));
|
||||
m.partition().apply_delete(*schema, clustering_key_prefix::make_empty(), tombstone(now, gc_clock::now()));
|
||||
|
||||
tracing::trace(_trace_state, "Sending a batchlog remove mutation");
|
||||
return send_batchlog_mutation(std::move(m), db::consistency_level::ANY).handle_exception([] (std::exception_ptr eptr) {
|
||||
|
||||
@@ -862,7 +862,7 @@ SEASTAR_TEST_CASE(datafile_generation_12) {
|
||||
auto mt = make_lw_shared<memtable>(s);
|
||||
|
||||
auto key = partition_key::from_exploded(*s, {to_bytes("key1")});
|
||||
auto cp = exploded_clustering_prefix({to_bytes("c1") });
|
||||
auto cp = clustering_key_prefix::from_exploded(*s, {to_bytes("c1")});
|
||||
|
||||
mutation m(key, s);
|
||||
|
||||
@@ -899,7 +899,7 @@ static future<> sstable_compression_test(compressor c, unsigned generation) {
|
||||
auto mtp = make_lw_shared<memtable>(s);
|
||||
|
||||
auto key = partition_key::from_exploded(*s, {to_bytes("key1")});
|
||||
auto cp = exploded_clustering_prefix({to_bytes("c1") });
|
||||
auto cp = clustering_key_prefix::from_exploded(*s, {to_bytes("c1")});
|
||||
|
||||
mutation m(key, s);
|
||||
|
||||
@@ -1392,7 +1392,7 @@ SEASTAR_TEST_CASE(datafile_generation_37) {
|
||||
auto key = partition_key::from_exploded(*s, {to_bytes("key1")});
|
||||
mutation m(key, s);
|
||||
|
||||
auto c_key = exploded_clustering_prefix({to_bytes("cl1") });
|
||||
auto c_key = clustering_key_prefix::from_exploded(*s, {to_bytes("c1")});
|
||||
const column_definition& cl2 = *s->get_column_definition("cl2");
|
||||
|
||||
m.set_clustered_cell(c_key, cl2, make_atomic_cell(bytes_type->decompose(data_value(to_bytes("cl2")))));
|
||||
@@ -1407,8 +1407,7 @@ SEASTAR_TEST_CASE(datafile_generation_37) {
|
||||
}).then([sstp, s] (auto mutation) {
|
||||
auto& mp = mutation->partition();
|
||||
|
||||
auto exploded = exploded_clustering_prefix({"cl1"});
|
||||
auto clustering = clustering_key::from_clustering_prefix(*s, exploded);
|
||||
auto clustering = clustering_key_prefix::from_exploded(*s, {to_bytes("cl1")});
|
||||
|
||||
auto row = mp.clustered_row(*s, clustering);
|
||||
match_live_cell(row.cells(), *s, "cl2", data_value(to_bytes("cl2")));
|
||||
@@ -1429,8 +1428,7 @@ SEASTAR_TEST_CASE(datafile_generation_38) {
|
||||
auto key = partition_key::from_exploded(*s, {to_bytes("key1")});
|
||||
mutation m(key, s);
|
||||
|
||||
auto exploded = exploded_clustering_prefix({"cl1", "cl2"});
|
||||
auto c_key = clustering_key::from_clustering_prefix(*s, exploded);
|
||||
auto c_key = clustering_key_prefix::from_exploded(*s, {to_bytes("cl1"), to_bytes("cl2")});
|
||||
|
||||
const column_definition& cl3 = *s->get_column_definition("cl3");
|
||||
m.set_clustered_cell(c_key, cl3, make_atomic_cell(bytes_type->decompose(data_value(to_bytes("cl3")))));
|
||||
@@ -1444,8 +1442,7 @@ SEASTAR_TEST_CASE(datafile_generation_38) {
|
||||
return mutation_from_streamed_mutation(std::move(sm));
|
||||
}).then([sstp, s] (auto mutation) {
|
||||
auto& mp = mutation->partition();
|
||||
auto exploded = exploded_clustering_prefix({"cl1", "cl2"});
|
||||
auto clustering = clustering_key::from_clustering_prefix(*s, exploded);
|
||||
auto clustering = clustering_key_prefix::from_exploded(*s, {to_bytes("cl1"), to_bytes("cl2")});
|
||||
|
||||
auto row = mp.clustered_row(*s, clustering);
|
||||
match_live_cell(row.cells(), *s, "cl3", data_value(to_bytes("cl3")));
|
||||
@@ -3249,7 +3246,7 @@ SEASTAR_TEST_CASE(sstable_tombstone_metadata_check) {
|
||||
.build();
|
||||
auto tmp = make_lw_shared<tmpdir>();
|
||||
auto key = partition_key::from_exploded(*s, {to_bytes("key1")});
|
||||
auto c_key = exploded_clustering_prefix({to_bytes("c1") });
|
||||
auto c_key = clustering_key_prefix::from_exploded(*s, {to_bytes("c1")});
|
||||
const column_definition& r1_col = *s->get_column_definition("r1");
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user