mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-21 17:10:35 +00:00
db: fix collection_type_impl::deserialize_mutation_form() types
It accepts a bytes_view instead of the type-safe wrapper.
This commit is contained in:
@@ -230,7 +230,7 @@ lists::setter_by_index::execute(mutation& m, const exploded_clustering_prefix& p
|
||||
|
||||
collection_mutation::view existing_list_ser = params.get_prefetched_list(m.key, row_key, column);
|
||||
auto ltype = dynamic_pointer_cast<list_type_impl>(column.type);
|
||||
collection_type_impl::mutation_view existing_list = ltype->deserialize_mutation_form(existing_list_ser.data);
|
||||
collection_type_impl::mutation_view existing_list = ltype->deserialize_mutation_form(existing_list_ser);
|
||||
// we verified that index is an int32_type
|
||||
auto idx = net::ntoh(int32_t(*unaligned_cast<int32_t>(index->begin())));
|
||||
if (idx < 0 || size_t(idx) >= existing_list.cells.size()) {
|
||||
|
||||
@@ -691,7 +691,7 @@ column_family::get_partition_slice(mutation_partition& partition, const query::p
|
||||
auto&& ctype = static_pointer_cast<collection_type_impl>(def.type);
|
||||
// cannot use mutation_view, since we'll modify some of the values
|
||||
// FIXME: work around this somehow
|
||||
collection_type_impl::mutation m = ctype->deserialize_mutation_form(cell.data).materialize();
|
||||
collection_type_impl::mutation m = ctype->deserialize_mutation_form(cell).materialize();
|
||||
for (auto&& e : m.cells) {
|
||||
auto& value = e.second;
|
||||
if (value.timestamp() < row_tombstone.timestamp) {
|
||||
|
||||
@@ -75,7 +75,7 @@ static future<> require_column_has_value(distributed<database>& ddb, const sstri
|
||||
} else {
|
||||
auto cell = i->second.as_collection_mutation();
|
||||
auto type = dynamic_pointer_cast<collection_type_impl>(col_def->type);
|
||||
actual = type->to_value(type->deserialize_mutation_form(cell.data),
|
||||
actual = type->to_value(type->deserialize_mutation_form(cell),
|
||||
serialization_format::internal());
|
||||
}
|
||||
assert(col_def->type->equal(actual, col_def->type->decompose(expected)));
|
||||
|
||||
@@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(test_map_mutations) {
|
||||
auto i = r.find(column.id);
|
||||
BOOST_REQUIRE(i != r.end());
|
||||
auto cell = i->second.as_collection_mutation();
|
||||
auto muts = my_map_type->deserialize_mutation_form(cell.data);
|
||||
auto muts = my_map_type->deserialize_mutation_form(cell);
|
||||
BOOST_REQUIRE(muts.cells.size() == 3);
|
||||
// FIXME: more strict tests
|
||||
}
|
||||
@@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(test_set_mutations) {
|
||||
auto i = r.find(column.id);
|
||||
BOOST_REQUIRE(i != r.end());
|
||||
auto cell = i->second.as_collection_mutation();
|
||||
auto muts = my_set_type->deserialize_mutation_form(cell.data);
|
||||
auto muts = my_set_type->deserialize_mutation_form(cell);
|
||||
BOOST_REQUIRE(muts.cells.size() == 3);
|
||||
// FIXME: more strict tests
|
||||
}
|
||||
@@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(test_list_mutations) {
|
||||
auto i = r.find(column.id);
|
||||
BOOST_REQUIRE(i != r.end());
|
||||
auto cell = i->second.as_collection_mutation();
|
||||
auto muts = my_list_type->deserialize_mutation_form(cell.data);
|
||||
auto muts = my_list_type->deserialize_mutation_form(cell);
|
||||
BOOST_REQUIRE(muts.cells.size() == 4);
|
||||
// FIXME: more strict tests
|
||||
}
|
||||
|
||||
7
types.cc
7
types.cc
@@ -927,7 +927,8 @@ map_type_impl::serialize_partially_deserialized_form(
|
||||
|
||||
}
|
||||
|
||||
auto collection_type_impl::deserialize_mutation_form(bytes_view in) -> mutation_view {
|
||||
auto collection_type_impl::deserialize_mutation_form(collection_mutation::view cm) -> mutation_view {
|
||||
auto&& in = cm.data;
|
||||
mutation_view ret;
|
||||
auto has_tomb = read_simple<bool>(in);
|
||||
if (has_tomb) {
|
||||
@@ -1000,8 +1001,8 @@ collection_type_impl::serialize_mutation_form(mutation_view mut) {
|
||||
|
||||
collection_mutation::one
|
||||
collection_type_impl::merge(collection_mutation::view a, collection_mutation::view b) {
|
||||
auto aa = deserialize_mutation_form(a.data);
|
||||
auto bb = deserialize_mutation_form(b.data);
|
||||
auto aa = deserialize_mutation_form(a);
|
||||
auto bb = deserialize_mutation_form(b);
|
||||
mutation_view merged;
|
||||
merged.cells.reserve(aa.cells.size() + bb.cells.size());
|
||||
using element_type = std::pair<bytes_view, atomic_cell_view>;
|
||||
|
||||
2
types.hh
2
types.hh
@@ -332,7 +332,7 @@ public:
|
||||
virtual shared_ptr<cql3::cql3_type> as_cql3_type() override;
|
||||
template <typename BytesViewIterator>
|
||||
static bytes pack(BytesViewIterator start, BytesViewIterator finish, int elements, serialization_format sf);
|
||||
mutation_view deserialize_mutation_form(bytes_view in);
|
||||
mutation_view deserialize_mutation_form(collection_mutation::view in);
|
||||
virtual bytes to_value(mutation_view mut, serialization_format sf) = 0;
|
||||
// FIXME: use iterators?
|
||||
collection_mutation::one serialize_mutation_form(const mutation& mut);
|
||||
|
||||
Reference in New Issue
Block a user