mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-01 21:55:50 +00:00
Holding keys and their prefixes as "bytes" is error prone. It's easy to mix them up (or use wrong types). This change adds wrappers for keys with accessors which are meant to make misuses as difficult as possible. Prefix and full keys are now distinguished. Places which assumed that the representation is the same (it currently is) were changed not to do so. This will allow us to introduce more compact storage for non-prefix keys.
27 lines
862 B
C++
27 lines
862 B
C++
#include "database.hh"
|
|
#include "perf.hh"
|
|
|
|
static atomic_cell::one make_atomic_cell(bytes value) {
|
|
return atomic_cell::one::make_live(0, ttl_opt{}, value);
|
|
};
|
|
|
|
int main(int argc, char* argv[]) {
|
|
auto s = make_lw_shared(schema("ks", "cf",
|
|
{{"p1", utf8_type}}, {{"c1", int32_type}}, {{"r1", int32_type}}, {}, utf8_type));
|
|
|
|
column_family cf(s);
|
|
|
|
std::cout << "Timing mutation of single column within one row...\n";
|
|
|
|
auto key = partition_key::one::from_exploded(*s, {to_bytes("key1")});
|
|
auto c_key = clustering_key::one::from_exploded(*s, {int32_type->decompose(2)});
|
|
bytes value = int32_type->decompose(3);
|
|
|
|
time_it([&] {
|
|
mutation m(key, s);
|
|
column_definition& col = *s->get_column_definition("r1");
|
|
m.set_clustered_cell(c_key, col, make_atomic_cell(value));
|
|
cf.apply(std::move(m));
|
|
});
|
|
}
|