everywhere: Use serialized(foo) instead of data_value(foo).serialize()

This is just a simple cleanup that reduces the size of another patch I
am working on and is an independent improvement.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
Message-Id: <20200114051739.370127-1-espindola@scylladb.com>
This commit is contained in:
Rafael Ávila de Espíndola
2020-01-13 21:17:39 -08:00
committed by Avi Kivity
parent b9f28e9335
commit dca1bc480f
10 changed files with 41 additions and 41 deletions

View File

@@ -253,7 +253,7 @@ make_timeuuidtounixtimestamp_fct() {
inline bytes time_point_to_long(const data_value& v) {
auto since_epoch = value_cast<db_clock::time_point>(v).time_since_epoch();
int64_t ms = std::chrono::duration_cast<std::chrono::milliseconds>(since_epoch).count();
return data_value(ms).serialize();
return serialized(ms);
}
inline

View File

@@ -297,9 +297,9 @@ SEASTAR_TEST_CASE(test_partition_version_consistency_after_lsa_compaction_happen
auto mt = make_lw_shared<memtable>(s);
auto empty_m = make_unique_mutation(s);
auto ck1 = clustering_key::from_single_value(*s, data_value(make_unique_bytes()).serialize());
auto ck2 = clustering_key::from_single_value(*s, data_value(make_unique_bytes()).serialize());
auto ck3 = clustering_key::from_single_value(*s, data_value(make_unique_bytes()).serialize());
auto ck1 = clustering_key::from_single_value(*s, serialized(make_unique_bytes()));
auto ck2 = clustering_key::from_single_value(*s, serialized(make_unique_bytes()));
auto ck3 = clustering_key::from_single_value(*s, serialized(make_unique_bytes()));
auto m1 = empty_m;
m1.set_clustered_cell(ck1, to_bytes("col"), data_value(bytes(bytes::initialized_later(), 8)), next_timestamp());
@@ -372,7 +372,7 @@ SEASTAR_TEST_CASE(test_segment_migration_during_flush) {
for (auto& m : ring) {
for (int i = 0; i < rows_per_partition; ++i) {
auto ck = clustering_key::from_single_value(*s, data_value(make_unique_bytes()).serialize());
auto ck = clustering_key::from_single_value(*s, serialized(make_unique_bytes()));
auto col_value = data_value(bytes(bytes::initialized_later(), 8));
m.set_clustered_cell(ck, to_bytes("col"), col_value, next_timestamp());
}

View File

@@ -2469,8 +2469,8 @@ SEASTAR_THREAD_TEST_CASE(test_multishard_combining_reader_next_partition) {
for (int pk = 0; pk < partition_count; ++pk) {
env.execute_prepared(insert_id, {{
cql3::raw_value::make_value(data_value(pk).serialize()),
cql3::raw_value::make_value(data_value(0).serialize())}}).get();
cql3::raw_value::make_value(serialized(pk)),
cql3::raw_value::make_value(serialized(0))}}).get();
}
auto schema = env.local_db().find_column_family("multishard_combining_reader_next_partition_ks", "test").schema();
@@ -2668,8 +2668,8 @@ SEASTAR_THREAD_TEST_CASE(test_multishard_streaming_reader) {
for (int pk = 0; pk < partition_count; ++pk) {
env.execute_prepared(insert_id, {{
cql3::raw_value::make_value(data_value(pk).serialize()),
cql3::raw_value::make_value(data_value(0).serialize())}}).get();
cql3::raw_value::make_value(serialized(pk)),
cql3::raw_value::make_value(serialized(0))}}).get();
}
auto schema = env.local_db().find_column_family("multishard_streaming_reader_ks", "test").schema();

View File

@@ -644,9 +644,9 @@ SEASTAR_THREAD_TEST_CASE(test_resources_based_cache_eviction) {
env.require_table_exists("querier_cache", "test").get();
auto insert_id = env.prepare("INSERT INTO querier_cache.test (pk, ck, value) VALUES (?, ?, ?);").get0();
auto pk = cql3::raw_value::make_value(data_value(0).serialize());
auto pk = cql3::raw_value::make_value(serialized(0));
for (int i = 0; i < 100; ++i) {
auto ck = cql3::raw_value::make_value(data_value(i).serialize());
auto ck = cql3::raw_value::make_value(serialized(i));
env.execute_prepared(insert_id, {{pk, ck, ck}}).get();
}

View File

@@ -2865,7 +2865,7 @@ SEASTAR_TEST_CASE(test_continuity_population_with_multicolumn_clustering_key) {
memtable_snapshot_source underlying(s);
auto pk = dht::global_partitioner().decorate_key(*s,
partition_key::from_single_value(*s, data_value(3).serialize()));
partition_key::from_single_value(*s, serialized(3)));
auto pr = dht::partition_range::make_singular(pk);
auto ck1 = clustering_key::from_deeply_exploded(*s, {data_value(1), data_value(1)});

View File

@@ -71,7 +71,7 @@ std::pair<schema_ptr, std::vector<dht::decorated_key>> create_test_table(cql_tes
explicit simple_partition_content_generator(int pk, int row_count) : _pk(pk), _row_count(row_count) {
}
virtual partition_key generate_partition_key(const schema& schema) override {
return partition_key::from_single_value(schema, data_value(_pk).serialize());
return partition_key::from_single_value(schema, serialized(_pk));
}
virtual bool has_static_row() override {
return false;
@@ -87,7 +87,7 @@ std::pair<schema_ptr, std::vector<dht::decorated_key>> create_test_table(cql_tes
const auto data = _pk ^ ck;
auto buf = bytes(bytes::initialized_later{}, sizeof(int));
std::copy_n(&data, 1, reinterpret_cast<int*>(buf.data()));
return row{clustering_key::from_single_value(schema, data_value(ck).serialize()), std::move(buf)};
return row{clustering_key::from_single_value(schema, serialized(ck)), std::move(buf)};
}
virtual query::clustering_row_ranges generate_delete_ranges(const schema&, const std::vector<clustering_key>&) override {
return {};
@@ -132,7 +132,7 @@ population_description create_test_table(cql_test_env& env, const sstring& ks_na
, _key_dist(std::numeric_limits<int>::min(), std::numeric_limits<int>::max()) {
}
virtual partition_key generate_partition_key(const schema& schema) override {
return partition_key::from_single_value(schema, data_value(_key_dist(_engine)).serialize());
return partition_key::from_single_value(schema, serialized(_key_dist(_engine)));
}
virtual bool has_static_row() override {
return _config.static_row_size_dist.has_value();
@@ -144,7 +144,7 @@ population_description create_test_table(cql_test_env& env, const sstring& ks_na
return _config.clustering_row_count_dist(_engine);
}
virtual row generate_row(const schema& schema, const partition_key& pk) override {
auto ck = clustering_key::from_single_value(schema, data_value(_key_dist(_engine)).serialize());
auto ck = clustering_key::from_single_value(schema, serialized(_key_dist(_engine)));
auto value = _gen_blob(schema, _config.clustering_row_size_dist(_engine), pk, &ck);
return row{std::move(ck), std::move(value)};
}
@@ -229,7 +229,7 @@ static size_t maybe_generate_static_row(cql_test_env& env, const schema& schema,
env.execute_prepared(static_insert_id, {{
cql3::raw_value::make_value(bytes(part_desc.dkey.key().get_component(schema, 0))),
cql3::raw_value::make_value(data_value(std::move(value)).serialize())}}).get();
cql3::raw_value::make_value(serialized(std::move(value)))}}).get();
return size;
}
@@ -285,7 +285,7 @@ static clustering_row_generation_result generate_clustering_rows(
env.execute_prepared(clustering_insert_id, {{
cql3::raw_value::make_value(bytes(part_desc.dkey.key().get_component(schema, 0))),
cql3::raw_value::make_value(bytes(key.get_component(schema, 0))),
cql3::raw_value::make_value(data_value(std::move(value)).serialize())}}).get();
cql3::raw_value::make_value(serialized(std::move(value)))}}).get();
written_rows.insert(std::move(key));
}
@@ -464,7 +464,7 @@ population_description create_test_table(cql_test_env& env, const sstring& ks_na
// We don't expect this to fail, this is here more to validate our
// expectation of the population, then the correctness of writes.
auto msg = env.execute_cql(format("SELECT COUNT(*) FROM {}.{}", ks_name, table_name)).get0();
assert_that(msg).is_rows().with_rows({{data_value(int64_t(live_row_count)).serialize()}});
assert_that(msg).is_rows().with_rows({{serialized(int64_t(live_row_count))}});
tlog.info("Done. Population summary: written {} partitions, {} rows, {} range tombstones and {} bytes;"
" have (after de-duplication) {} partitions, {} live rows and {} dead rows.",

View File

@@ -82,7 +82,7 @@ public:
}
clustering_key make_ckey(sstring ck) {
return clustering_key::from_single_value(*_s, data_value(ck).serialize());
return clustering_key::from_single_value(*_s, serialized(ck));
}
query::clustering_range make_ckey_range(uint32_t start_inclusive, uint32_t end_inclusive) {
@@ -101,7 +101,7 @@ public:
}
dht::decorated_key make_pkey(sstring pk) {
auto key = partition_key::from_single_value(*_s, data_value(pk).serialize());
auto key = partition_key::from_single_value(*_s, serialized(pk));
return dht::global_partitioner().decorate_key(*_s, key);
}
@@ -110,7 +110,7 @@ public:
t = new_timestamp();
}
const column_definition& v_def = get_v_def(*_s);
m.set_clustered_cell(key, v_def, atomic_cell::make_live(*v_def.type, t, data_value(v).serialize()));
m.set_clustered_cell(key, v_def, atomic_cell::make_live(*v_def.type, t, serialized(v)));
return t;
}
@@ -130,7 +130,7 @@ public:
mutation_fragment make_row(const clustering_key& key, sstring v) {
auto row = clustering_row(key);
const column_definition& v_def = get_v_def(*_s);
row.cells().apply(v_def, atomic_cell::make_live(*v_def.type, new_timestamp(), data_value(v).serialize()));
row.cells().apply(v_def, atomic_cell::make_live(*v_def.type, new_timestamp(), serialized(v)));
return mutation_fragment(std::move(row));
}

View File

@@ -141,7 +141,7 @@ int main(int argc, char** argv) {
stats_printer.arm_periodic(1s);
auto make_pkey = [s] (sstring pk) {
auto key = partition_key::from_single_value(*s, data_value(pk).serialize());
auto key = partition_key::from_single_value(*s, serialized(pk));
return dht::global_partitioner().decorate_key(*s, key);
};
@@ -168,9 +168,9 @@ int main(int argc, char** argv) {
int32_t ckey_seq = 0;
while (!cancelled) {
mutation m(s, pkey);
auto ck = clustering_key::from_single_value(*s, data_value(ckey_seq++).serialize());
auto ck = clustering_key::from_single_value(*s, serialized(ckey_seq++));
auto&& col = *s->get_column_definition(to_bytes("v"));
m.set_clustered_cell(ck, col, atomic_cell::make_live(*col.type, api::new_timestamp(), data_value(value).serialize()));
m.set_clustered_cell(ck, col, atomic_cell::make_live(*col.type, api::new_timestamp(), serialized(value)));
auto t0 = clock::now();
db.apply(s, freeze(m)).get();
writes_hist.add(std::chrono::duration_cast<std::chrono::microseconds>(clock::now() - t0).count());

View File

@@ -919,7 +919,7 @@ public:
virtual int n_rows(const table_config&) = 0;
clustering_key make_ck(const schema& s, int ck) {
return clustering_key::from_single_value(s, data_value(ck).serialize());
return clustering_key::from_single_value(s, serialized(ck));
}
};
@@ -945,9 +945,9 @@ public:
large_part_ds1() : simple_large_part_ds("large-part-ds1", "One large partition with many small rows") {}
generator_fn make_generator(schema_ptr s, const table_config& cfg) override {
auto value = data_value(make_blob(cfg.value_size));
auto value = serialized(make_blob(cfg.value_size));
auto& value_cdef = *s->get_column_definition("value");
auto pk = partition_key::from_single_value(*s, data_value(0).serialize());
auto pk = partition_key::from_single_value(*s, serialized(0));
return [this, s, ck = 0, n_ck = n_rows(cfg), &value_cdef, value, pk] () mutable -> std::optional<mutation> {
if (ck == n_ck) {
return std::nullopt;
@@ -955,7 +955,7 @@ public:
auto ts = api::new_timestamp();
mutation m(s, pk);
auto& row = m.partition().clustered_row(*s, make_ck(*s, ck));
row.cells().apply(value_cdef, atomic_cell::make_live(*value_cdef.type, ts, value.serialize()));
row.cells().apply(value_cdef, atomic_cell::make_live(*value_cdef.type, ts, value));
++ck;
return m;
};
@@ -968,16 +968,16 @@ public:
"create table {} (pk int, value blob, primary key (pk))") {}
generator_fn make_generator(schema_ptr s, const table_config& cfg) override {
auto value = data_value(make_blob(cfg.value_size));
auto value = serialized(make_blob(cfg.value_size));
auto& value_cdef = *s->get_column_definition("value");
return [s, pk = 0, n_pk = n_partitions(cfg), &value_cdef, value] () mutable -> std::optional<mutation> {
if (pk == n_pk) {
return std::nullopt;
}
auto ts = api::new_timestamp();
mutation m(s, partition_key::from_single_value(*s, data_value(pk).serialize()));
mutation m(s, partition_key::from_single_value(*s, serialized(pk)));
auto& row = m.partition().clustered_row(*s, clustering_key::make_empty());
row.cells().apply(value_cdef, atomic_cell::make_live(*value_cdef.type, ts, value.serialize()));
row.cells().apply(value_cdef, atomic_cell::make_live(*value_cdef.type, ts, value));
++pk;
return m;
};

View File

@@ -124,7 +124,7 @@ void run_test(const sstring& name, schema_ptr s, MutationGenerator&& gen) {
auto mt = make_lw_shared<memtable>(s);
while (mt->occupancy().total_space() < memtable_size) {
auto pk = dht::global_partitioner().decorate_key(*s, partition_key::from_single_value(*s,
data_value(utils::UUID_gen::get_time_UUID()).serialize()));
serialized(utils::UUID_gen::get_time_UUID())));
mutation m = gen();
mt->apply(m);
if (cancelled) {
@@ -205,7 +205,7 @@ void test_small_partitions() {
run_test("Small partitions, no overwrites", s, [&] {
auto pk = dht::global_partitioner().decorate_key(*s, partition_key::from_single_value(*s,
data_value(utils::UUID_gen::get_time_UUID()).serialize()));
serialized(utils::UUID_gen::get_time_UUID())));
mutation m(s, pk);
auto val = data_value(bytes(bytes::initialized_later(), cell_size));
m.set_clustered_cell(clustering_key::make_empty(), "v1", val, api::new_timestamp());
@@ -225,13 +225,13 @@ void test_partition_with_lots_of_small_rows() {
.build();
auto pk = dht::global_partitioner().decorate_key(*s, partition_key::from_single_value(*s,
data_value(utils::UUID_gen::get_time_UUID()).serialize()));
serialized(utils::UUID_gen::get_time_UUID())));
int ck_idx = 0;
run_test("Large partition, lots of small rows", s, [&] {
mutation m(s, pk);
auto val = data_value(bytes(bytes::initialized_later(), cell_size));
auto ck = clustering_key::from_single_value(*s, data_value(ck_idx++).serialize());
auto ck = clustering_key::from_single_value(*s, serialized(ck_idx++));
m.set_clustered_cell(ck, "v1", val, api::new_timestamp());
m.set_clustered_cell(ck, "v2", val, api::new_timestamp());
m.set_clustered_cell(ck, "v3", val, api::new_timestamp());
@@ -250,13 +250,13 @@ void test_partition_with_few_small_rows() {
run_test("Small partition with a few rows", s, [&] {
auto pk = dht::global_partitioner().decorate_key(*s, partition_key::from_single_value(*s,
data_value(utils::UUID_gen::get_time_UUID()).serialize()));
serialized(utils::UUID_gen::get_time_UUID())));
mutation m(s, pk);
auto val = data_value(bytes(bytes::initialized_later(), cell_size));
for (int i = 0; i < 3; ++i) {
auto ck = clustering_key::from_single_value(*s, data_value(i).serialize());
auto ck = clustering_key::from_single_value(*s, serialized(i));
m.set_clustered_cell(ck, "v1", val, api::new_timestamp());
m.set_clustered_cell(ck, "v2", val, api::new_timestamp());
m.set_clustered_cell(ck, "v3", val, api::new_timestamp());
@@ -275,13 +275,13 @@ void test_partition_with_lots_of_range_tombstones() {
.build();
auto pk = dht::global_partitioner().decorate_key(*s, partition_key::from_single_value(*s,
data_value(utils::UUID_gen::get_time_UUID()).serialize()));
serialized(utils::UUID_gen::get_time_UUID())));
int ck_idx = 0;
run_test("Large partition, lots of range tombstones", s, [&] {
mutation m(s, pk);
auto val = data_value(bytes(bytes::initialized_later(), cell_size));
auto ck = clustering_key::from_single_value(*s, data_value(ck_idx++).serialize());
auto ck = clustering_key::from_single_value(*s, serialized(ck_idx++));
auto r = query::clustering_range::make({ck}, {ck});
tombstone tomb(api::new_timestamp(), gc_clock::now());
m.partition().apply_row_tombstone(*s, range_tombstone(bound_view::from_range_start(r), bound_view::from_range_end(r), tomb));