db: Drop api:: namespace from mutation model classes
In preparation for merging into database.hh
This commit is contained in:
@@ -336,7 +336,7 @@ public:
|
||||
public:
|
||||
using operation::operation;
|
||||
|
||||
virtual void execute(api::mutation& m, const api::clustering_prefix& prefix, const update_parameters& params) override {
|
||||
virtual void execute(mutation& m, const clustering_prefix& prefix, const update_parameters& params) override {
|
||||
bytes_opt value = _t->bind_and_get(params._options);
|
||||
auto cell = value ? params.make_cell(*value) : params.make_dead_cell();
|
||||
if (column.is_static()) {
|
||||
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
/**
|
||||
* Execute the operation.
|
||||
*/
|
||||
virtual void execute(api::mutation& m, const api::clustering_prefix& row_key, const update_parameters& params) = 0;
|
||||
virtual void execute(mutation& m, const clustering_prefix& row_key, const update_parameters& params) = 0;
|
||||
|
||||
/**
|
||||
* A parsed raw UPDATE operation.
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace cql3 {
|
||||
|
||||
namespace statements {
|
||||
|
||||
void delete_statement::add_update_for_key(api::mutation& m, const api::clustering_prefix& prefix, const update_parameters& params) {
|
||||
void delete_statement::add_update_for_key(mutation& m, const clustering_prefix& prefix, const update_parameters& params) {
|
||||
if (_column_operations.empty()) {
|
||||
m.p.apply_delete(prefix, params.make_tombstone());
|
||||
return;
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void add_update_for_key(api::mutation& m, const api::clustering_prefix& prefix, const update_parameters& params) override;
|
||||
virtual void add_update_for_key(mutation& m, const clustering_prefix& prefix, const update_parameters& params) override;
|
||||
|
||||
#if 0
|
||||
protected void validateWhereClauseForConditions() throws InvalidRequestException
|
||||
|
||||
@@ -50,13 +50,13 @@ operator<<(std::ostream& out, modification_statement::statement_type t) {
|
||||
return out;
|
||||
}
|
||||
|
||||
future<std::vector<api::mutation>>
|
||||
future<std::vector<mutation>>
|
||||
modification_statement::get_mutations(const query_options& options, bool local, int64_t now) {
|
||||
auto keys = make_lw_shared(build_partition_keys(options));
|
||||
auto prefix = make_lw_shared(create_clustering_prefix(options));
|
||||
return make_update_parameters(keys, prefix, options, local, now).then(
|
||||
[this, keys = std::move(keys), prefix = std::move(prefix), now] (auto params_ptr) {
|
||||
std::vector<api::mutation> mutations;
|
||||
std::vector<mutation> mutations;
|
||||
mutations.reserve(keys->size());
|
||||
for (auto key : *keys) {
|
||||
validation::validate_cql_key(s, key);
|
||||
@@ -70,8 +70,8 @@ modification_statement::get_mutations(const query_options& options, bool local,
|
||||
|
||||
future<std::unique_ptr<update_parameters>>
|
||||
modification_statement::make_update_parameters(
|
||||
lw_shared_ptr<std::vector<api::partition_key>> keys,
|
||||
lw_shared_ptr<api::clustering_prefix> prefix,
|
||||
lw_shared_ptr<std::vector<partition_key>> keys,
|
||||
lw_shared_ptr<clustering_prefix> prefix,
|
||||
const query_options& options,
|
||||
bool local,
|
||||
int64_t now) {
|
||||
@@ -87,8 +87,8 @@ modification_statement::make_update_parameters(
|
||||
|
||||
future<update_parameters::prefetched_rows_type>
|
||||
modification_statement::read_required_rows(
|
||||
lw_shared_ptr<std::vector<api::partition_key>> keys,
|
||||
lw_shared_ptr<api::clustering_prefix> prefix,
|
||||
lw_shared_ptr<std::vector<partition_key>> keys,
|
||||
lw_shared_ptr<clustering_prefix> prefix,
|
||||
bool local,
|
||||
db::consistency_level cl) {
|
||||
if (!requires_read()) {
|
||||
@@ -148,7 +148,7 @@ modification_statement::get_first_empty_key() {
|
||||
return {};
|
||||
}
|
||||
|
||||
api::clustering_prefix
|
||||
clustering_prefix
|
||||
modification_statement::create_clustering_prefix_internal(const query_options& options) {
|
||||
std::vector<bytes_opt> components;
|
||||
const column_definition* first_empty_key = nullptr;
|
||||
@@ -184,7 +184,7 @@ modification_statement::create_clustering_prefix_internal(const query_options& o
|
||||
return components;
|
||||
}
|
||||
|
||||
api::clustering_prefix
|
||||
clustering_prefix
|
||||
modification_statement::create_clustering_prefix(const query_options& options) {
|
||||
// If the only updated/deleted columns are static, then we don't need clustering columns.
|
||||
// And in fact, unless it is an INSERT, we reject if clustering columns are provided as that
|
||||
@@ -222,9 +222,9 @@ modification_statement::create_clustering_prefix(const query_options& options) {
|
||||
return create_clustering_prefix_internal(options);
|
||||
}
|
||||
|
||||
std::vector<api::partition_key>
|
||||
std::vector<partition_key>
|
||||
modification_statement::build_partition_keys(const query_options& options) {
|
||||
std::vector<api::partition_key> result;
|
||||
std::vector<partition_key> result;
|
||||
std::vector<bytes_opt> components;
|
||||
|
||||
auto remaining = s->partition_key.size();
|
||||
@@ -244,7 +244,7 @@ modification_statement::build_partition_keys(const query_options& options) {
|
||||
throw exceptions::invalid_request_exception(sprint("Invalid null value for partition key part %s", def.name_as_text()));
|
||||
}
|
||||
components.push_back(val);
|
||||
api::partition_key key = serialize_value(*s->partition_key_type, components);
|
||||
partition_key key = serialize_value(*s->partition_key_type, components);
|
||||
validation::validate_cql_key(s, key);
|
||||
result.push_back(key);
|
||||
} else {
|
||||
@@ -256,7 +256,7 @@ modification_statement::build_partition_keys(const query_options& options) {
|
||||
full_components.reserve(components.size() + 1);
|
||||
auto i = std::copy(components.begin(), components.end(), std::back_inserter(full_components));
|
||||
*i = val;
|
||||
api::partition_key key = serialize_value(*s->partition_key_type, full_components);
|
||||
partition_key key = serialize_value(*s->partition_key_type, full_components);
|
||||
validation::validate_cql_key(s, key);
|
||||
result.push_back(key);
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public:
|
||||
|
||||
virtual bool require_full_clustering_key() const = 0;
|
||||
|
||||
virtual void add_update_for_key(api::mutation& m, const api::clustering_prefix& prefix, const update_parameters& params) = 0;
|
||||
virtual void add_update_for_key(mutation& m, const clustering_prefix& prefix, const update_parameters& params) = 0;
|
||||
|
||||
virtual int get_bound_terms() override {
|
||||
return _bound_terms;
|
||||
@@ -267,11 +267,11 @@ private:
|
||||
public:
|
||||
void add_key_value(column_definition& def, ::shared_ptr<term> value);
|
||||
void process_where_clause(std::vector<relation_ptr> where_clause, ::shared_ptr<variable_specifications> names);
|
||||
std::vector<api::partition_key> build_partition_keys(const query_options& options);
|
||||
std::vector<partition_key> build_partition_keys(const query_options& options);
|
||||
|
||||
private:
|
||||
api::clustering_prefix create_clustering_prefix(const query_options& options);
|
||||
api::clustering_prefix create_clustering_prefix_internal(const query_options& options);
|
||||
clustering_prefix create_clustering_prefix(const query_options& options);
|
||||
clustering_prefix create_clustering_prefix_internal(const query_options& options);
|
||||
|
||||
protected:
|
||||
const column_definition* get_first_empty_key();
|
||||
@@ -285,8 +285,8 @@ public:
|
||||
|
||||
protected:
|
||||
future<update_parameters::prefetched_rows_type> read_required_rows(
|
||||
lw_shared_ptr<std::vector<api::partition_key>> keys,
|
||||
lw_shared_ptr<api::clustering_prefix> prefix,
|
||||
lw_shared_ptr<std::vector<partition_key>> keys,
|
||||
lw_shared_ptr<clustering_prefix> prefix,
|
||||
bool local,
|
||||
db::consistency_level cl);
|
||||
|
||||
@@ -435,12 +435,12 @@ private:
|
||||
* @return vector of the mutations
|
||||
* @throws invalid_request_exception on invalid requests
|
||||
*/
|
||||
future<std::vector<api::mutation>> get_mutations(const query_options& options, bool local, int64_t now);
|
||||
future<std::vector<mutation>> get_mutations(const query_options& options, bool local, int64_t now);
|
||||
|
||||
public:
|
||||
future<std::unique_ptr<update_parameters>> make_update_parameters(
|
||||
lw_shared_ptr<std::vector<api::partition_key>> keys,
|
||||
lw_shared_ptr<api::clustering_prefix> prefix,
|
||||
lw_shared_ptr<std::vector<partition_key>> keys,
|
||||
lw_shared_ptr<clustering_prefix> prefix,
|
||||
const query_options& options,
|
||||
bool local,
|
||||
int64_t now);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace cql3 {
|
||||
|
||||
namespace statements {
|
||||
|
||||
void update_statement::add_update_for_key(api::mutation& m, const api::clustering_prefix& prefix, const update_parameters& params) {
|
||||
void update_statement::add_update_for_key(mutation& m, const clustering_prefix& prefix, const update_parameters& params) {
|
||||
if (s->is_dense()) {
|
||||
throw std::runtime_error("Dense tables not supported yet");
|
||||
#if 0
|
||||
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void add_update_for_key(api::mutation& m, const api::clustering_prefix& prefix, const update_parameters& params) override;
|
||||
virtual void add_update_for_key(mutation& m, const clustering_prefix& prefix, const update_parameters& params) override;
|
||||
|
||||
class parsed_insert : public modification_statement::parsed {
|
||||
private:
|
||||
|
||||
@@ -36,8 +36,7 @@ namespace cql3 {
|
||||
class update_parameters final {
|
||||
public:
|
||||
using prefetched_rows_type = std::experimental::optional<
|
||||
std::unordered_map<api::partition_key, api::row,
|
||||
serialized_hash, serialized_equal>>;
|
||||
std::unordered_map<partition_key, row, serialized_hash, serialized_equal>>;
|
||||
private:
|
||||
const gc_clock::duration _ttl;
|
||||
const prefetched_rows_type _prefetched; // For operation that require a read-before-write
|
||||
@@ -64,19 +63,19 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
api::atomic_cell make_dead_cell() const {
|
||||
return api::atomic_cell{_timestamp, api::atomic_cell::dead{_local_deletion_time}};
|
||||
atomic_cell make_dead_cell() const {
|
||||
return atomic_cell{_timestamp, atomic_cell::dead{_local_deletion_time}};
|
||||
}
|
||||
|
||||
api::atomic_cell make_cell(bytes value) const {
|
||||
atomic_cell make_cell(bytes value) const {
|
||||
auto ttl = _ttl;
|
||||
|
||||
if (ttl.count() <= 0) {
|
||||
ttl = _schema->default_time_to_live;
|
||||
}
|
||||
|
||||
return api::atomic_cell{_timestamp,
|
||||
api::atomic_cell::live{ttl.count() > 0 ? ttl_opt{_local_deletion_time + ttl} : ttl_opt{}, std::move(value)}};
|
||||
return atomic_cell{_timestamp,
|
||||
atomic_cell::live{ttl.count() > 0 ? ttl_opt{_local_deletion_time + ttl} : ttl_opt{}, std::move(value)}};
|
||||
};
|
||||
|
||||
#if 0
|
||||
@@ -87,7 +86,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
api::tombstone make_tombstone() const {
|
||||
tombstone make_tombstone() const {
|
||||
return {_timestamp, _local_deletion_time};
|
||||
}
|
||||
|
||||
|
||||
16
db/api.hh
16
db/api.hh
@@ -13,8 +13,6 @@
|
||||
#include "database.hh"
|
||||
#include "db/consistency_level.hh"
|
||||
|
||||
namespace api {
|
||||
|
||||
using partition_key_type = tuple_type<>;
|
||||
using clustering_key_type = tuple_type<>;
|
||||
using clustering_prefix_type = tuple_prefix;
|
||||
@@ -22,27 +20,31 @@ using partition_key = bytes;
|
||||
using clustering_key = bytes;
|
||||
using clustering_prefix = clustering_prefix_type::value_type;
|
||||
|
||||
namespace api {
|
||||
|
||||
using timestamp_type = int64_t;
|
||||
timestamp_type constexpr missing_timestamp = std::numeric_limits<timestamp_type>::min();
|
||||
timestamp_type constexpr min_timestamp = std::numeric_limits<timestamp_type>::min() + 1;
|
||||
timestamp_type constexpr max_timestamp = std::numeric_limits<timestamp_type>::max();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents deletion operation. Can be commuted with other tombstones via apply() method.
|
||||
* Can be empty.
|
||||
*
|
||||
*/
|
||||
struct tombstone final {
|
||||
timestamp_type timestamp;
|
||||
api::timestamp_type timestamp;
|
||||
gc_clock::time_point ttl;
|
||||
|
||||
tombstone(timestamp_type timestamp, gc_clock::time_point ttl)
|
||||
tombstone(api::timestamp_type timestamp, gc_clock::time_point ttl)
|
||||
: timestamp(timestamp)
|
||||
, ttl(ttl)
|
||||
{ }
|
||||
|
||||
tombstone()
|
||||
: tombstone(missing_timestamp, {})
|
||||
: tombstone(api::missing_timestamp, {})
|
||||
{ }
|
||||
|
||||
bool operator<(const tombstone& t) const {
|
||||
@@ -54,7 +56,7 @@ struct tombstone final {
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return timestamp != missing_timestamp;
|
||||
return timestamp != api::missing_timestamp;
|
||||
}
|
||||
|
||||
void apply(const tombstone& t) {
|
||||
@@ -179,5 +181,3 @@ public:
|
||||
row[def.id] = std::move(value);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ namespace service {
|
||||
* @param consistency_level the consistency level for the operation
|
||||
*/
|
||||
future<>
|
||||
storage_proxy::mutate(std::vector<api::mutation> mutations, db::consistency_level cl) {
|
||||
storage_proxy::mutate(std::vector<mutation> mutations, db::consistency_level cl) {
|
||||
throw std::runtime_error("NOT IMPLEMENTED");
|
||||
#if 0
|
||||
Tracing.trace("Determining replicas for mutation");
|
||||
@@ -559,7 +559,7 @@ storage_proxy::mutate(std::vector<api::mutation> mutations, db::consistency_leve
|
||||
}
|
||||
|
||||
future<>
|
||||
storage_proxy::mutate_with_triggers(std::vector<api::mutation> mutations, db::consistency_level cl,
|
||||
storage_proxy::mutate_with_triggers(std::vector<mutation> mutations, db::consistency_level cl,
|
||||
bool should_mutate_atomically) {
|
||||
unimplemented::triggers();
|
||||
#if 0
|
||||
@@ -587,7 +587,7 @@ storage_proxy::mutate_with_triggers(std::vector<api::mutation> mutations, db::co
|
||||
* @param consistency_level the consistency level for the operation
|
||||
*/
|
||||
future<>
|
||||
storage_proxy::mutate_atomically(std::vector<api::mutation> mutations, db::consistency_level cl) {
|
||||
storage_proxy::mutate_atomically(std::vector<mutation> mutations, db::consistency_level cl) {
|
||||
unimplemented::lwt();
|
||||
#if 0
|
||||
Tracing.trace("Determining replicas for atomic batch");
|
||||
|
||||
@@ -39,9 +39,9 @@ public:
|
||||
* @param mutations the mutations to be applied across the replicas
|
||||
* @param consistency_level the consistency level for the operation
|
||||
*/
|
||||
static future<> mutate(std::vector<api::mutation> mutations, db::consistency_level cl);
|
||||
static future<> mutate(std::vector<mutation> mutations, db::consistency_level cl);
|
||||
|
||||
static future<> mutate_with_triggers(std::vector<api::mutation> mutations,
|
||||
static future<> mutate_with_triggers(std::vector<mutation> mutations,
|
||||
db::consistency_level cl, bool should_mutate_atomically);
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
* @param mutations the Mutations to be applied across the replicas
|
||||
* @param consistency_level the consistency level for the operation
|
||||
*/
|
||||
static future<> mutate_atomically(std::vector<api::mutation> mutations, db::consistency_level cl);
|
||||
static future<> mutate_atomically(std::vector<mutation> mutations, db::consistency_level cl);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace validation {
|
||||
* Based on org.apache.cassandra.thrift.ThriftValidation#validate_key()
|
||||
*/
|
||||
void
|
||||
validate_cql_key(schema_ptr schema, const api::partition_key& key) {
|
||||
validate_cql_key(schema_ptr schema, const partition_key& key) {
|
||||
if (key.empty()) {
|
||||
throw exceptions::invalid_request_exception("Key may not be empty");
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace validation {
|
||||
|
||||
constexpr size_t max_key_size = std::numeric_limits<uint16_t>::max();
|
||||
|
||||
void validate_cql_key(schema_ptr schema, const api::partition_key& key);
|
||||
void validate_cql_key(schema_ptr schema, const partition_key& key);
|
||||
schema_ptr validate_column_family(database& db, const sstring& keyspace_name, const sstring& cf_name);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user