diff --git a/alternator/executor.cc b/alternator/executor.cc index c935f464d1..0aa90c498c 100644 --- a/alternator/executor.cc +++ b/alternator/executor.cc @@ -2657,7 +2657,7 @@ mutation put_or_delete_item::build(schema_ptr schema, api::timestamp_type ts) co } auto attrs = attrs_column(*schema); if (!attrs_collector.empty()) { - auto serialized_map = attrs_collector.to_mut().serialize(*attrs_type()); + auto serialized_map = attrs_collector.to_mut().serialize(); row.cells().apply(attrs, std::move(serialized_map)); } // To allow creation of an item with no attributes, we need a row marker. @@ -2680,7 +2680,7 @@ mutation put_or_delete_item::build(schema_ptr schema, api::timestamp_type ts) co // Scylla to handle collection replacements in CQL (see #6084, PR #6491, // e.g. cql3::maps::setter::execute()) and we utilize it to avoid // emitting the REMOVE event (resolving #6930). - row.cells().apply(attrs, collection_mutation_description{tombstone{ts - 1, gc_clock::now()}}.serialize(*attrs.type)); + row.cells().apply(attrs, collection_mutation_description{tombstone{ts - 1, gc_clock::now()}}.serialize()); // Note that for old tables created with regular LSI and GSI key columns, // we must also delete the regular columns that are not part of the new // schema consisting of pk, ck, and :attrs. @@ -4312,7 +4312,7 @@ std::optional update_item_operation::apply(std::unique_ptrcolumn_at(column_kind::static_column, nonatomic_update.id); - m.set_static_cell(cdef, collection_mutation_description{nonatomic_update.t, std::move(nonatomic_update.cells)}.serialize(*cdef.type)); + m.set_static_cell(cdef, collection_mutation_description{nonatomic_update.t, std::move(nonatomic_update.cells)}.serialize()); } processor.process_change(m); } @@ -654,7 +654,7 @@ void process_changes_with_splitting(const mutation& base_mutation, change_proces } for (auto& nonatomic_update : cr_insert.nonatomic_entries) { auto& cdef = base_schema->column_at(column_kind::regular_column, nonatomic_update.id); - row.cells().apply(cdef, collection_mutation_description{nonatomic_update.t, std::move(nonatomic_update.cells)}.serialize(*cdef.type)); + row.cells().apply(cdef, collection_mutation_description{nonatomic_update.t, std::move(nonatomic_update.cells)}.serialize()); } row.apply(cr_insert.marker); @@ -671,7 +671,7 @@ void process_changes_with_splitting(const mutation& base_mutation, change_proces } for (auto& nonatomic_update : cr_update.nonatomic_entries) { auto& cdef = base_schema->column_at(column_kind::regular_column, nonatomic_update.id); - row.apply(cdef, collection_mutation_description{nonatomic_update.t, std::move(nonatomic_update.cells)}.serialize(*cdef.type)); + row.apply(cdef, collection_mutation_description{nonatomic_update.t, std::move(nonatomic_update.cells)}.serialize()); } processor.process_change(m); diff --git a/cql3/constants.cc b/cql3/constants.cc index 7e8e51599f..eea32abf16 100644 --- a/cql3/constants.cc +++ b/cql3/constants.cc @@ -56,7 +56,7 @@ void constants::deleter::execute(mutation& m, const clustering_key_prefix& prefi collection_mutation_description coll_m; coll_m.tomb = params.make_tombstone(); - m.set_cell(prefix, column, coll_m.serialize(*column.type)); + m.set_cell(prefix, column, coll_m.serialize()); } else { m.set_cell(prefix, column, params.make_dead_cell()); } diff --git a/cql3/lists.cc b/cql3/lists.cc index ee584e6b39..a3f665877f 100644 --- a/cql3/lists.cc +++ b/cql3/lists.cc @@ -43,7 +43,7 @@ lists::setter::execute(mutation& m, const clustering_key_prefix& prefix, const u collection_mutation_view_description mut; mut.tomb = params.make_tombstone_just_before(); - m.set_cell(prefix, column, mut.serialize(*column.type)); + m.set_cell(prefix, column, mut.serialize()); } do_append(value, m, prefix, column, params); } @@ -94,7 +94,7 @@ lists::setter_by_index::execute(mutation& m, const clustering_key_prefix& prefix params.make_cell(*ltype->value_comparator(), value.view(), atomic_cell::collection_member::yes)); } - m.set_cell(prefix, column, mut.serialize(*ltype)); + m.set_cell(prefix, column, mut.serialize()); } bool @@ -127,7 +127,7 @@ lists::setter_by_uuid::execute(mutation& m, const clustering_key_prefix& prefix, params.make_cell(*ltype->value_comparator(), value.view(), atomic_cell::collection_member::yes)); } - m.set_cell(prefix, column, mut.serialize(*ltype)); + m.set_cell(prefix, column, mut.serialize()); } void @@ -172,7 +172,7 @@ lists::do_append(const cql3::raw_value& list_value, throw exceptions::invalid_request_exception("Too many list values per single CQL statement or batch"); } } - m.set_cell(prefix, column, appended.serialize(*ltype)); + m.set_cell(prefix, column, appended.serialize()); } else { auto ltype = static_cast(column.type.get()); // for frozen lists, we're overwriting the whole cell value @@ -234,7 +234,7 @@ lists::prepender::execute(mutation& m, const clustering_key_prefix& prefix, cons throw exceptions::invalid_request_exception("Too many list values per single CQL statement or batch"); } } - m.set_cell(prefix, column, mut.serialize(*ltype)); + m.set_cell(prefix, column, mut.serialize()); } bool @@ -290,7 +290,7 @@ lists::discarder::execute(mutation& m, const clustering_key_prefix& prefix, cons mnew.cells.emplace_back(std::move(eidx), params.make_dead_cell()); } } - m.set_cell(prefix, column, mnew.serialize(*ltype)); + m.set_cell(prefix, column, mnew.serialize()); } bool @@ -320,7 +320,7 @@ lists::discarder_by_index::execute(mutation& m, const clustering_key_prefix& pre const data_value& eidx_dv = existing_list[idx].first; bytes eidx = eidx_dv.type()->decompose(eidx_dv); mut.cells.emplace_back(std::move(eidx), params.make_dead_cell()); - m.set_cell(prefix, column, mut.serialize(*column.type)); + m.set_cell(prefix, column, mut.serialize()); } } diff --git a/cql3/maps.cc b/cql3/maps.cc index d056a17e1a..120a70e4fa 100644 --- a/cql3/maps.cc +++ b/cql3/maps.cc @@ -31,7 +31,7 @@ maps::setter::execute(mutation& m, const clustering_key_prefix& row_key, const u // Delete all cells first, then put new ones collection_mutation_description mut; mut.tomb = params.make_tombstone_just_before(); - m.set_cell(row_key, column, mut.serialize(*column.type)); + m.set_cell(row_key, column, mut.serialize()); } do_put(m, row_key, params, value, column); } @@ -58,7 +58,7 @@ maps::setter_by_key::execute(mutation& m, const clustering_key_prefix& prefix, c collection_mutation_description update; update.cells.emplace_back(std::move(key).to_bytes(), std::move(avalue)); - m.set_cell(prefix, column, update.serialize(*ctype)); + m.set_cell(prefix, column, update.serialize()); } void @@ -83,7 +83,7 @@ maps::do_put(mutation& m, const clustering_key_prefix& prefix, const update_para mut.cells.emplace_back(to_bytes(e.first), params.make_cell(*ctype->get_values_type(), raw_value_view::make_value(e.second), atomic_cell::collection_member::yes)); } - m.set_cell(prefix, column, mut.serialize(*ctype)); + m.set_cell(prefix, column, mut.serialize()); } else { // for frozen maps, we're overwriting the whole cell if (map_value.is_null()) { @@ -104,7 +104,7 @@ maps::discarder_by_key::execute(mutation& m, const clustering_key_prefix& prefix collection_mutation_description mut; mut.cells.emplace_back(std::move(key).to_bytes(), params.make_dead_cell()); - m.set_cell(prefix, column, mut.serialize(*column.type)); + m.set_cell(prefix, column, mut.serialize()); } } diff --git a/cql3/sets.cc b/cql3/sets.cc index da5492817a..3370427c51 100644 --- a/cql3/sets.cc +++ b/cql3/sets.cc @@ -26,7 +26,7 @@ sets::setter::execute(mutation& m, const clustering_key_prefix& row_key, const u // Delete all cells first, then add new ones collection_mutation_description mut; mut.tomb = params.make_tombstone_just_before(); - m.set_cell(row_key, column, mut.serialize(*column.type)); + m.set_cell(row_key, column, mut.serialize()); } adder::do_add(m, row_key, params, value, column); } @@ -63,7 +63,7 @@ sets::adder::do_add(mutation& m, const clustering_key_prefix& row_key, const upd mut.cells.emplace_back(to_bytes(*e), params.make_cell(*set_type.value_comparator(), bytes_view(), atomic_cell::collection_member::yes)); } - m.set_cell(row_key, column, mut.serialize(set_type)); + m.set_cell(row_key, column, mut.serialize()); } else if (!value.is_null()) { // for frozen sets, we're overwriting the whole cell value.view().with_value([&] (const FragmentedView auto& v) { @@ -93,7 +93,7 @@ sets::discarder::execute(mutation& m, const clustering_key_prefix& row_key, cons } mut.cells.push_back({to_bytes(*e), params.make_dead_cell()}); } - m.set_cell(row_key, column, mut.serialize(*column.type)); + m.set_cell(row_key, column, mut.serialize()); } void sets::element_discarder::execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params) @@ -105,7 +105,7 @@ void sets::element_discarder::execute(mutation& m, const clustering_key_prefix& } collection_mutation_description mut; mut.cells.emplace_back(std::move(elt).to_bytes(), params.make_dead_cell()); - m.set_cell(row_key, column, mut.serialize(*column.type)); + m.set_cell(row_key, column, mut.serialize()); } } diff --git a/cql3/user_types.cc b/cql3/user_types.cc index 7f5962a998..d03494beeb 100644 --- a/cql3/user_types.cc +++ b/cql3/user_types.cc @@ -60,7 +60,7 @@ void user_types::setter::execute(mutation& m, const clustering_key_prefix& row_k } } - m.set_cell(row_key, column, mut.serialize(type)); + m.set_cell(row_key, column, mut.serialize()); } else { if (!ut_value.is_null()) { m.set_cell(row_key, column, params.make_cell(type, ut_value.view())); @@ -82,7 +82,7 @@ void user_types::setter_by_field::execute(mutation& m, const clustering_key_pref ? params.make_cell(*type.type(_field_idx), value.view(), atomic_cell::collection_member::yes) : params.make_dead_cell()); - m.set_cell(row_key, column, mut.serialize(type)); + m.set_cell(row_key, column, mut.serialize()); } void user_types::deleter_by_field::execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params) { @@ -91,7 +91,7 @@ void user_types::deleter_by_field::execute(mutation& m, const clustering_key_pre collection_mutation_description mut; mut.cells.emplace_back(serialize_field_index(_field_idx), params.make_dead_cell()); - m.set_cell(row_key, column, mut.serialize(*column.type)); + m.set_cell(row_key, column, mut.serialize()); } } diff --git a/db/schema_tables.cc b/db/schema_tables.cc index 63db6d6e17..1d618223a5 100644 --- a/db/schema_tables.cc +++ b/db/schema_tables.cc @@ -1127,7 +1127,7 @@ make_map_mutation(const Map& map, mut.cells.emplace_back(ktyp->decompose(data_value(te.first)), atomic_cell::make_live(*vtyp, timestamp, vtyp->decompose(data_value(te.second)), atomic_cell::collection_member::yes)); } - return mut.serialize(*column_type); + return mut.serialize(); } else { map_type_impl::native_type tmp; tmp.reserve(map.size()); @@ -1390,7 +1390,7 @@ make_list_mutation(const std::vector& values, atomic_cell::make_live(*vtyp, timestamp, vtyp->decompose(std::move(dv)), atomic_cell::collection_member::yes)); } - return m.serialize(*column_type); + return m.serialize(); } else { list_type_impl::native_type tmp; tmp.reserve(values.size()); diff --git a/db/view/view.cc b/db/view/view.cc index 69c16854c9..e14825e5ca 100644 --- a/db/view/view.cc +++ b/db/view/view.cc @@ -732,7 +732,7 @@ static collection_mutation make_empty( n.cells.emplace_back(c.first, make_empty(c.second)); } }); - return n.serialize(type); + return n.serialize(); } // In some cases, we need to copy to a view table even columns which have not diff --git a/mutation/collection_mutation.cc b/mutation/collection_mutation.cc index 473276101c..43bb906671 100644 --- a/mutation/collection_mutation.cc +++ b/mutation/collection_mutation.cc @@ -33,10 +33,10 @@ bool collection_mutation_input_stream::empty() const { return _src.empty(); } -collection_mutation::collection_mutation(const abstract_type& type, collection_mutation_view v) +collection_mutation::collection_mutation(collection_mutation_view v) : _data(v.data) {} -collection_mutation::collection_mutation(const abstract_type& type, managed_bytes data) +collection_mutation::collection_mutation(managed_bytes data) : _data(std::move(data)) {} collection_mutation::operator collection_mutation_view() const @@ -241,7 +241,6 @@ concept CollectionMutationAdaptor = requires(const Element& e, managed_bytes_mut template requires CollectionMutationAdaptor> static collection_mutation serialize_collection_mutation( - const abstract_type& type, const tombstone& tomb, std::ranges::subrange cells) { auto element_size = [] (size_t c, auto&& e) -> size_t { @@ -273,7 +272,7 @@ static collection_mutation serialize_collection_mutation( writek(kv); writev(kv); } - return collection_mutation(type, std::move(ret)); + return collection_mutation(std::move(ret)); } namespace { @@ -300,12 +299,12 @@ struct atomic_cell_adaptor { } -collection_mutation collection_mutation_description::serialize(const abstract_type& type) const { - return serialize_collection_mutation(type, tomb, std::ranges::subrange(cells.begin(), cells.end())); +collection_mutation collection_mutation_description::serialize() const { + return serialize_collection_mutation(tomb, std::ranges::subrange(cells.begin(), cells.end())); } -collection_mutation collection_mutation_view_description::serialize(const abstract_type& type) const { - return serialize_collection_mutation(type, tomb, std::ranges::subrange(cells.begin(), cells.end())); +collection_mutation collection_mutation_view_description::serialize() const { + return serialize_collection_mutation(tomb, std::ranges::subrange(cells.begin(), cells.end())); } namespace { @@ -364,7 +363,7 @@ struct serialized_cell_adaptor { collection_mutation read_from_collection_cell_view(const abstract_type& type, const ser::collection_cell_view& collection) { auto tomb = collection.tomb(); auto cells = collection.elements(); - return serialize_collection_mutation(type, tomb, std::ranges::subrange(cells.begin(), cells.end())); + return serialize_collection_mutation(tomb, std::ranges::subrange(cells.begin(), cells.end())); } template @@ -424,7 +423,7 @@ collection_mutation merge(const abstract_type& type, collection_mutation_view a, [] (const abstract_type& o) -> collection_mutation_view_description { throw std::runtime_error(format("collection_mutation merge: unknown type: {}", o.name())); } - )).serialize(type); + )).serialize(); }); }); } @@ -470,7 +469,7 @@ collection_mutation difference(const abstract_type& type, collection_mutation_vi [] (const abstract_type& o) -> collection_mutation_view_description { throw std::runtime_error(format("collection_mutation difference: unknown type: {}", o.name())); } - )).serialize(type); + )).serialize(); }); }); } diff --git a/mutation/collection_mutation.hh b/mutation/collection_mutation.hh index 7f515d79f8..953d752283 100644 --- a/mutation/collection_mutation.hh +++ b/mutation/collection_mutation.hh @@ -44,7 +44,7 @@ struct collection_mutation_description { can_gc_fn&, gc_clock::time_point gc_before, compaction_garbage_collector* collector = nullptr); // Packs the data to a serialized blob. - collection_mutation serialize(const abstract_type&) const; + collection_mutation serialize() const; }; // Similar to collection_mutation_description, except that it doesn't store the cells' data, only observes it. @@ -57,7 +57,7 @@ struct collection_mutation_view_description { collection_mutation_description materialize(const abstract_type&) const; // Packs the data to a serialized blob. - collection_mutation serialize(const abstract_type&) const; + collection_mutation serialize() const; }; class collection_mutation_input_stream { @@ -125,8 +125,8 @@ public: managed_bytes _data; collection_mutation() {} - collection_mutation(const abstract_type&, collection_mutation_view); - collection_mutation(const abstract_type&, managed_bytes); + collection_mutation(collection_mutation_view); + collection_mutation(managed_bytes); operator collection_mutation_view() const; }; diff --git a/mutation/converting_mutation_partition_applier.cc b/mutation/converting_mutation_partition_applier.cc index c86f3949d0..6a646a1eba 100644 --- a/mutation/converting_mutation_partition_applier.cc +++ b/mutation/converting_mutation_partition_applier.cc @@ -87,7 +87,7 @@ converting_mutation_partition_applier::accept_cell(row& dst, column_kind kind, c )); if (new_view.tomb || !new_view.cells.empty()) { - dst.apply(new_def, new_view.serialize(*new_def.type)); + dst.apply(new_def, new_view.serialize()); } }); } diff --git a/mutation/mutation_compactor.hh b/mutation/mutation_compactor.hh index ec6d87c4f0..1b7e2e8c2e 100644 --- a/mutation/mutation_compactor.hh +++ b/mutation/mutation_compactor.hh @@ -88,7 +88,7 @@ public: virtual void collect(column_id id, collection_mutation_description mut) override { if (mut.tomb || !mut.cells.empty()) { const auto& cdef = _schema.column_at(_kind, id); - _row.apply(cdef, mut.serialize(*cdef.type)); + _row.apply(cdef, mut.serialize()); } } virtual void collect(row_marker marker) override { diff --git a/mutation/mutation_partition.cc b/mutation/mutation_partition.cc index 25655afff9..d4e027345c 100644 --- a/mutation/mutation_partition.cc +++ b/mutation/mutation_partition.cc @@ -1664,7 +1664,7 @@ compact_and_expire_result row::compact_and_expire( if (m.cells.empty() && m.tomb <= tomb.tomb()) { erase = true; } else { - c = m.serialize(*def.type); + c = m.serialize(); } }); } diff --git a/mutation_writer/timestamp_based_splitting_writer.cc b/mutation_writer/timestamp_based_splitting_writer.cc index 0a08ffa874..31dd013a5d 100644 --- a/mutation_writer/timestamp_based_splitting_writer.cc +++ b/mutation_writer/timestamp_based_splitting_writer.cc @@ -290,7 +290,7 @@ timestamp_based_splitting_mutation_writer::split_collection(atomic_cell_or_colle } for (auto&& [bucket, bucket_mv] : mutations_by_bucket) { - pieces_by_bucket.emplace(bucket, bucket_mv.serialize(*cdef.type)); + pieces_by_bucket.emplace(bucket, bucket_mv.serialize()); } }); diff --git a/partition_builder.hh b/partition_builder.hh index 50e7209cd0..9237e3fabe 100644 --- a/partition_builder.hh +++ b/partition_builder.hh @@ -46,7 +46,7 @@ public: } virtual void accept_static_cell(column_id id, collection_mutation_view collection) override { - accept_static_cell(id, collection_mutation(*_schema.static_column_at(id).type, std::move(collection))); + accept_static_cell(id, collection_mutation(std::move(collection))); } void accept_static_cell(column_id id, collection_mutation&& collection) { @@ -76,7 +76,7 @@ public: } virtual void accept_row_cell(column_id id, collection_mutation_view collection) override { - accept_row_cell(id, collection_mutation(*_schema.regular_column_at(id).type, std::move(collection))); + accept_row_cell(id, collection_mutation(std::move(collection))); } void accept_row_cell(column_id id, collection_mutation collection) { @@ -136,7 +136,7 @@ public: virtual void accept_static_cell(column_id id, collection_mutation_view collection) override { row& r = _partition->static_row().maybe_create(); - r.append_cell(id, collection_mutation(*_schema->static_column_at(id).type, std::move(collection))); + r.append_cell(id, collection_mutation(std::move(collection))); } virtual future<> accept_row_tombstone(const range_tombstone& rt) override { @@ -166,7 +166,7 @@ public: virtual void accept_row_cell(column_id id, collection_mutation_view collection) override { row& r = _current_row->cells(); - r.append_cell(id, collection_mutation(*_schema->regular_column_at(id).type, std::move(collection))); + r.append_cell(id, collection_mutation(std::move(collection))); } virtual future<> accept_end_of_partition() override { diff --git a/service/topology_mutation.cc b/service/topology_mutation.cc index 8da9eb5940..03d2309ed4 100644 --- a/service/topology_mutation.cc +++ b/service/topology_mutation.cc @@ -69,7 +69,7 @@ Builder& topology_mutation_builder_base::apply_set(const char* cell, co cm.tomb = tombstone(self().timestamp() - 1, gc_clock::now()); } - self().row().apply(*cdef, cm.serialize(*cdef->type)); + self().row().apply(*cdef, cm.serialize()); return self(); } @@ -84,7 +84,7 @@ Builder& topology_mutation_builder_base::del(const char* cell) { } else { collection_mutation_description cm; cm.tomb = tombstone{self().timestamp(), gc_clock::now()}; - self().row().apply(*cdef, cm.serialize(*cdef->type)); + self().row().apply(*cdef, cm.serialize()); } return self(); } diff --git a/sstables/kl/reader.cc b/sstables/kl/reader.cc index 8f9335be44..cc3b236bb9 100644 --- a/sstables/kl/reader.cc +++ b/sstables/kl/reader.cc @@ -252,7 +252,7 @@ private: if (!_cdef) { return; } - auto ac = atomic_cell_or_collection::from_collection_mutation(cm.serialize(*_cdef->type)); + auto ac = atomic_cell_or_collection::from_collection_mutation(cm.serialize()); if (_cdef->is_static()) { mf.mutate_as_static_row(s, [&] (static_row& sr) mutable { sr.set_cell(*_cdef, std::move(ac)); diff --git a/sstables/mx/reader.cc b/sstables/mx/reader.cc index 8fcd41910b..0a1ffb5a70 100644 --- a/sstables/mx/reader.cc +++ b/sstables/mx/reader.cc @@ -450,7 +450,7 @@ public: const column_definition& column_def = get_column_definition(column_id); if (!_cm.cells.empty() || (_cm.tomb && _cm.tomb.timestamp > column_def.dropped_at())) { check_schema_mismatch(column_info, column_def); - _cells.push_back({column_def.id, _cm.serialize(*column_def.type)}); + _cells.push_back({column_def.id, _cm.serialize()}); } } _cm.tomb = {}; diff --git a/test/boost/frozen_mutation_test.cc b/test/boost/frozen_mutation_test.cc index 5e3edc9c6b..e055de80a6 100644 --- a/test/boost/frozen_mutation_test.cc +++ b/test/boost/frozen_mutation_test.cc @@ -245,7 +245,7 @@ SEASTAR_THREAD_TEST_CASE(test_freeze_unfreeze_with_large_collection_cells) { for (size_t i = 0; i < num_entries; ++i) { cmd.cells.emplace_back(int32_type->decompose(int32_t(i)), make_atomic_cell(atomic_cell::collection_member::yes)); } - m.set_clustered_cell(ck, cdef_collection, atomic_cell_or_collection(cmd.serialize(*collection_type))); + m.set_clustered_cell(ck, cdef_collection, atomic_cell_or_collection(cmd.serialize())); } for (auto do_freeze_gently : {false, true}) { diff --git a/test/boost/mutation_test.cc b/test/boost/mutation_test.cc index fdf67c491d..488c3c5918 100644 --- a/test/boost/mutation_test.cc +++ b/test/boost/mutation_test.cc @@ -242,19 +242,19 @@ SEASTAR_TEST_CASE(test_map_mutations) { auto& column = *s->get_column_definition("s1"); auto mmut1 = make_collection_mutation({}, int32_type->decompose(101), make_collection_member(utf8_type, sstring("101"))); mutation m1(s, key); - m1.set_static_cell(column, mmut1.serialize(*my_map_type)); + m1.set_static_cell(column, mmut1.serialize()); mt->apply(m1); auto mmut2 = make_collection_mutation({}, int32_type->decompose(102), make_collection_member(utf8_type, sstring("102"))); mutation m2(s, key); - m2.set_static_cell(column, mmut2.serialize(*my_map_type)); + m2.set_static_cell(column, mmut2.serialize()); mt->apply(m2); auto mmut3 = make_collection_mutation({}, int32_type->decompose(103), make_collection_member(utf8_type, sstring("103"))); mutation m3(s, key); - m3.set_static_cell(column, mmut3.serialize(*my_map_type)); + m3.set_static_cell(column, mmut3.serialize()); mt->apply(m3); auto mmut2o = make_collection_mutation({}, int32_type->decompose(102), make_collection_member(utf8_type, sstring("102 override"))); mutation m2o(s, key); - m2o.set_static_cell(column, mmut2o.serialize(*my_map_type)); + m2o.set_static_cell(column, mmut2o.serialize()); mt->apply(m2o); auto p = get_partition(semaphore.make_permit(), *mt, key); @@ -283,19 +283,19 @@ SEASTAR_TEST_CASE(test_set_mutations) { auto& column = *s->get_column_definition("s1"); auto mmut1 = make_collection_mutation({}, int32_type->decompose(101), make_atomic_cell()); mutation m1(s, key); - m1.set_static_cell(column, mmut1.serialize(*my_set_type)); + m1.set_static_cell(column, mmut1.serialize()); mt->apply(m1); auto mmut2 = make_collection_mutation({}, int32_type->decompose(102), make_atomic_cell()); mutation m2(s, key); - m2.set_static_cell(column, mmut2.serialize(*my_set_type)); + m2.set_static_cell(column, mmut2.serialize()); mt->apply(m2); auto mmut3 = make_collection_mutation({}, int32_type->decompose(103), make_atomic_cell()); mutation m3(s, key); - m3.set_static_cell(column, mmut3.serialize(*my_set_type)); + m3.set_static_cell(column, mmut3.serialize()); mt->apply(m3); auto mmut2o = make_collection_mutation({}, int32_type->decompose(102), make_atomic_cell()); mutation m2o(s, key); - m2o.set_static_cell(column, mmut2o.serialize(*my_set_type)); + m2o.set_static_cell(column, mmut2o.serialize()); mt->apply(m2o); auto p = get_partition(semaphore.make_permit(), *mt, key); @@ -325,19 +325,19 @@ SEASTAR_TEST_CASE(test_list_mutations) { auto make_key = [] { return timeuuid_type->decompose(utils::UUID_gen::get_time_UUID()); }; auto mmut1 = make_collection_mutation({}, make_key(), make_collection_member(int32_type, 101)); mutation m1(s, key); - m1.set_static_cell(column, mmut1.serialize(*my_list_type)); + m1.set_static_cell(column, mmut1.serialize()); mt->apply(m1); auto mmut2 = make_collection_mutation({}, make_key(), make_collection_member(int32_type, 102)); mutation m2(s, key); - m2.set_static_cell(column, mmut2.serialize(*my_list_type)); + m2.set_static_cell(column, mmut2.serialize()); mt->apply(m2); auto mmut3 = make_collection_mutation({}, make_key(), make_collection_member(int32_type, 103)); mutation m3(s, key); - m3.set_static_cell(column, mmut3.serialize(*my_list_type)); + m3.set_static_cell(column, mmut3.serialize()); mt->apply(m3); auto mmut2o = make_collection_mutation({}, make_key(), make_collection_member(int32_type, 102)); mutation m2o(s, key); - m2o.set_static_cell(column, mmut2o.serialize(*my_list_type)); + m2o.set_static_cell(column, mmut2o.serialize()); mt->apply(m2o); auto p = get_partition(semaphore.make_permit(), *mt, key); @@ -373,19 +373,19 @@ SEASTAR_THREAD_TEST_CASE(test_udt_mutations) { auto mut1 = make_collection_mutation({}, serialize_field_index(0), make_collection_member(int32_type, 0), serialize_field_index(2), make_collection_member(long_type, int64_t(2))); mutation m1(s, key); - m1.set_static_cell(column, mut1.serialize(*ut)); + m1.set_static_cell(column, mut1.serialize()); mt->apply(m1); // {d: "text"} auto mut2 = make_collection_mutation({}, serialize_field_index(3), make_collection_member(utf8_type, "text")); mutation m2(s, key); - m2.set_static_cell(column, mut2.serialize(*ut)); + m2.set_static_cell(column, mut2.serialize()); mt->apply(m2); // {c: 3} auto mut3 = make_collection_mutation({}, serialize_field_index(2), make_collection_member(long_type, int64_t(3))); mutation m3(s, key); - m3.set_static_cell(column, mut3.serialize(*ut)); + m3.set_static_cell(column, mut3.serialize()); mt->apply(m3); auto p = get_partition(semaphore.make_permit(), *mt, key); @@ -446,7 +446,7 @@ SEASTAR_THREAD_TEST_CASE(test_large_collection_allocation) { mutation mut(schema, pk); row r; - r.apply(cdef, atomic_cell_or_collection(cmd.serialize(*collection_type))); + r.apply(cdef, atomic_cell_or_collection(cmd.serialize())); mut.apply(mutation_fragment(*schema, semaphore.make_permit(), clustering_row(clustering_key_prefix::make_empty(), {}, {}, std::move(r)))); return mut; @@ -507,10 +507,10 @@ SEASTAR_THREAD_TEST_CASE(test_large_collection_serialization_exception_safety) { } // We need an undisturbed run first to create all thread_local variables. - cmd.serialize(*collection_type); + cmd.serialize(); memory::with_allocation_failures([&] { - cmd.serialize(*collection_type); + cmd.serialize(); }); } @@ -1277,7 +1277,7 @@ SEASTAR_TEST_CASE(test_mutation_diff) { m1.set_clustered_cell(ckey2, *s->get_column_definition("v2"), atomic_cell::make_live(*bytes_type, 2, bytes_type->decompose(data_value(bytes("v2:value4"))))); auto mset1 = make_collection_mutation({}, int32_type->decompose(1), make_atomic_cell(), int32_type->decompose(2), make_atomic_cell()); - m1.set_clustered_cell(ckey2, *s->get_column_definition("v3"), mset1.serialize(*my_set_type)); + m1.set_clustered_cell(ckey2, *s->get_column_definition("v3"), mset1.serialize()); mutation m2(s, partition_key::from_single_value(*s, "key1")); m2.set_clustered_cell(ckey1, *s->get_column_definition("v1"), @@ -1290,7 +1290,7 @@ SEASTAR_TEST_CASE(test_mutation_diff) { m2.set_clustered_cell(ckey2, *s->get_column_definition("v2"), atomic_cell::make_live(*bytes_type, 3, bytes_type->decompose(data_value(bytes("v2:value4a"))))); auto mset2 = make_collection_mutation({}, int32_type->decompose(1), make_atomic_cell(), int32_type->decompose(3), make_atomic_cell()); - m2.set_clustered_cell(ckey2, *s->get_column_definition("v3"), mset2.serialize(*my_set_type)); + m2.set_clustered_cell(ckey2, *s->get_column_definition("v3"), mset2.serialize()); mutation m3(s, partition_key::from_single_value(*s, "key1")); m3.set_clustered_cell(ckey1, *s->get_column_definition("v1"), @@ -1301,7 +1301,7 @@ SEASTAR_TEST_CASE(test_mutation_diff) { m3.set_clustered_cell(ckey2, *s->get_column_definition("v2"), atomic_cell::make_live(*bytes_type, 3, bytes_type->decompose(data_value(bytes("v2:value4a"))))); auto mset3 = make_collection_mutation({}, int32_type->decompose(1), make_atomic_cell()); - m3.set_clustered_cell(ckey2, *s->get_column_definition("v3"), mset3.serialize(*my_set_type)); + m3.set_clustered_cell(ckey2, *s->get_column_definition("v3"), mset3.serialize()); mutation m12(s, partition_key::from_single_value(*s, "key1")); m12.apply(m1); @@ -1992,12 +1992,12 @@ SEASTAR_TEST_CASE(test_collection_cell_diff) { mcol1.cells.emplace_back( bytes(reinterpret_cast(uuid.data()), uuid.size()), atomic_cell::make_live(*bytes_type, api::timestamp_type(1), to_bytes("element"))); - m1.set_clustered_cell(clustering_key::make_empty(), col, mcol1.serialize(*col.type)); + m1.set_clustered_cell(clustering_key::make_empty(), col, mcol1.serialize()); mutation m2(s, k); collection_mutation_description mcol2; mcol2.tomb = tombstone(api::timestamp_type(2), gc_clock::now()); - m2.set_clustered_cell(clustering_key::make_empty(), col, mcol2.serialize(*col.type)); + m2.set_clustered_cell(clustering_key::make_empty(), col, mcol2.serialize()); mutation m12 = m1; m12.apply(m2); @@ -2621,7 +2621,7 @@ SEASTAR_THREAD_TEST_CASE(test_cell_external_memory_usage) { auto collection_type = map_type_impl::get_instance(int32_type, bytes_type, true); auto m = make_collection_mutation({ }, int32_type->decompose(0), make_collection_member(bytes_type, data_value(bytes(bv)))); - auto cell = atomic_cell_or_collection(m.serialize(*collection_type)); + auto cell = atomic_cell_or_collection(m.serialize()); with_allocator(alloc, [&] { auto before = alloc.allocated_bytes(); @@ -3881,7 +3881,7 @@ SEASTAR_TEST_CASE(test_compact_and_expire_cell_stats) { collection_mutation_description desc; desc.tomb = tomb; do_make_collection(desc, std::forward(cells)...); - return desc.serialize(*collection_type); + return desc.serialize(); }; const auto check = [&] (row_content rc, row_tombstone rt, compact_and_expire_result expected_res, std::source_location sl = std::source_location::current()) { @@ -3898,7 +3898,7 @@ SEASTAR_TEST_CASE(test_compact_and_expire_cell_stats) { } if (rc.collection_column) { const auto cdef = *s.get_column_definition(column_names.at(col_kind)[1]); - r.apply(cdef, atomic_cell_or_collection(collection_mutation(*collection_type, *rc.collection_column))); + r.apply(cdef, atomic_cell_or_collection(collection_mutation(*rc.collection_column))); } auto res = r.compact_and_expire(s, col_kind, rt, now, always_gc, now); BOOST_REQUIRE_EQUAL(res, expected_res); diff --git a/test/boost/sstable_3_x_test.cc b/test/boost/sstable_3_x_test.cc index 6be8dbbac5..a084e7bf0c 100644 --- a/test/boost/sstable_3_x_test.cc +++ b/test/boost/sstable_3_x_test.cc @@ -3620,7 +3620,7 @@ SEASTAR_TEST_CASE(test_write_collection_wide_update) { set_values.cells.emplace_back(int32_type->decompose(2), atomic_cell::make_live(*bytes_type, write_timestamp, bytes_view{})); set_values.cells.emplace_back(int32_type->decompose(3), atomic_cell::make_live(*bytes_type, write_timestamp, bytes_view{})); - mut.set_clustered_cell(clustering_key::make_empty(), *s->get_column_definition("col"), set_values.serialize(*set_of_ints_type)); + mut.set_clustered_cell(clustering_key::make_empty(), *s->get_column_definition("col"), set_values.serialize()); write_mut_and_validate(env, s, table_name, mut); }); @@ -3644,7 +3644,7 @@ SEASTAR_TEST_CASE(test_write_collection_incremental_update) { collection_mutation_description set_values; set_values.cells.emplace_back(int32_type->decompose(2), atomic_cell::make_live(*bytes_type, write_timestamp, bytes_view{})); - mut.set_clustered_cell(clustering_key::make_empty(), *s->get_column_definition("col"), set_values.serialize(*set_of_ints_type)); + mut.set_clustered_cell(clustering_key::make_empty(), *s->get_column_definition("col"), set_values.serialize()); write_mut_and_validate(env, s, table_name, mut); }); @@ -4937,7 +4937,7 @@ SEASTAR_TEST_CASE(test_write_interleaved_atomic_and_collection_columns) { set_values.tomb = tombstone {write_timestamp - 1, write_time_point}; set_values.cells.emplace_back(int32_type->decompose(3), atomic_cell::make_live(*bytes_type, write_timestamp, bytes_view{})); set_values.cells.emplace_back(int32_type->decompose(4), atomic_cell::make_live(*bytes_type, write_timestamp, bytes_view{})); - mut.set_clustered_cell(ckey, *s->get_column_definition("rc4"), set_values.serialize(*set_of_ints_type)); + mut.set_clustered_cell(ckey, *s->get_column_definition("rc4"), set_values.serialize()); mut.set_cell(ckey, "rc5", data_value{5}, write_timestamp); @@ -4976,7 +4976,7 @@ SEASTAR_TEST_CASE(test_write_static_interleaved_atomic_and_collection_columns) { set_values.tomb = tombstone {write_timestamp - 1, write_time_point}; set_values.cells.emplace_back(int32_type->decompose(3), atomic_cell::make_live(*bytes_type, write_timestamp, bytes_view{})); set_values.cells.emplace_back(int32_type->decompose(4), atomic_cell::make_live(*bytes_type, write_timestamp, bytes_view{})); - mut.set_static_cell(*s->get_column_definition("st4"), set_values.serialize(*set_of_ints_type)); + mut.set_static_cell(*s->get_column_definition("st4"), set_values.serialize()); mut.set_static_cell("st5", data_value{5}, write_timestamp); @@ -5794,7 +5794,7 @@ SEASTAR_TEST_CASE(test_legacy_udt_in_collection_table) { collection_mutation_description desc; desc.cells.emplace_back(int32_type->decompose(0), atomic_cell::make_live(*ut, write_timestamp, ut->decompose(ut_val), atomic_cell::collection_member::yes)); - mut.set_clustered_cell(ckey, *m_cdef, desc.serialize(*m_type)); + mut.set_clustered_cell(ckey, *m_cdef, desc.serialize()); } // fm = {0: {a: 0, b: 0}} @@ -5805,7 +5805,7 @@ SEASTAR_TEST_CASE(test_legacy_udt_in_collection_table) { collection_mutation_description desc; desc.cells.emplace_back(int32_type->decompose(0), atomic_cell::make_live(*fm_type, write_timestamp, fm_type->decompose(fm_val), atomic_cell::collection_member::yes)); - mut.set_clustered_cell(ckey, *mm_cdef, desc.serialize(*mm_type)); + mut.set_clustered_cell(ckey, *mm_cdef, desc.serialize()); } // fmm = {0: {0: {a: 0, b: 0}}}, @@ -5816,7 +5816,7 @@ SEASTAR_TEST_CASE(test_legacy_udt_in_collection_table) { collection_mutation_description desc; desc.cells.emplace_back(ut->decompose(ut_val), atomic_cell::make_live(*bytes_type, write_timestamp, bytes{}, atomic_cell::collection_member::yes)); - mut.set_clustered_cell(ckey, *s_cdef, desc.serialize(*s_type)); + mut.set_clustered_cell(ckey, *s_cdef, desc.serialize()); } // fs = {{a: 0, b: 0}}, @@ -5827,7 +5827,7 @@ SEASTAR_TEST_CASE(test_legacy_udt_in_collection_table) { collection_mutation_description desc; desc.cells.emplace_back(timeuuid_type->decompose(utils::UUID("7fb27e80-7b12-11ea-9fad-f4d108a9e4a3")), atomic_cell::make_live(*ut, write_timestamp, ut->decompose(ut_val), atomic_cell::collection_member::yes)); - mut.set_clustered_cell(ckey, *l_cdef, desc.serialize(*l_type)); + mut.set_clustered_cell(ckey, *l_cdef, desc.serialize()); } // fl = [{a: 0, b: 0}] diff --git a/test/boost/sstable_datafile_test.cc b/test/boost/sstable_datafile_test.cc index 99a5beee4e..c493c41826 100644 --- a/test/boost/sstable_datafile_test.cc +++ b/test/boost/sstable_datafile_test.cc @@ -141,16 +141,16 @@ SEASTAR_TEST_CASE(datafile_generation_11) { set_mut.cells.emplace_back(to_bytes("2"), make_atomic_cell(bytes_type, {})); set_mut.cells.emplace_back(to_bytes("3"), make_atomic_cell(bytes_type, {})); - m.set_clustered_cell(c_key, set_col, set_mut.serialize(*set_col.type)); + m.set_clustered_cell(c_key, set_col, set_mut.serialize()); - m.set_static_cell(static_set_col, set_mut.serialize(*static_set_col.type)); + m.set_static_cell(static_set_col, set_mut.serialize()); auto key2 = partition_key::from_exploded(*s, {to_bytes("key2")}); mutation m2(s, key2); collection_mutation_description set_mut_single; set_mut_single.cells.emplace_back(to_bytes("4"), make_atomic_cell(bytes_type, {})); - m2.set_clustered_cell(c_key, set_col, set_mut_single.serialize(*set_col.type)); + m2.set_clustered_cell(c_key, set_col, set_mut_single.serialize()); auto mt = make_memtable(s, {std::move(m), std::move(m2)}).get(); diff --git a/test/lib/data_model.cc b/test/lib/data_model.cc index 99146e2c78..5409a0f13a 100644 --- a/test/lib/data_model.cc +++ b/test/lib/data_model.cc @@ -135,7 +135,7 @@ mutation mutation_description::build(schema_ptr s) const { atomic_cell::collection_member::yes)); } } - m.set_static_cell(*cdef, mut.serialize(*cdef->type)); + m.set_static_cell(*cdef, mut.serialize()); } ), value_or_collection); } @@ -186,7 +186,7 @@ mutation mutation_description::build(schema_ptr s) const { } } - m.set_clustered_cell(ck, *cdef, mut.serialize(*cdef->type)); + m.set_clustered_cell(ck, *cdef, mut.serialize()); } ), value_or_collection); } diff --git a/test/lib/mutation_source_test.cc b/test/lib/mutation_source_test.cc index c7585183da..e673257c4f 100644 --- a/test/lib/mutation_source_test.cc +++ b/test/lib/mutation_source_test.cc @@ -2290,7 +2290,7 @@ public: std::sort(m.cells.begin(), m.cells.end(), [] (auto&& c1, auto&& c2) { return timeuuid_type->as_less_comparator()(c1.first, c2.first); }); - return m.serialize(*ctype); + return m.serialize(); }; auto get_dead_cell = [&] () -> atomic_cell_or_collection{ if (col.is_atomic() || col.is_counter()) { @@ -2298,7 +2298,7 @@ public: } collection_mutation_description m; m.tomb = tombstone(gen_timestamp(timestamp_level::collection_tombstone), new_expiry()); - return m.serialize(*col.type); + return m.serialize(); }; // FIXME: generate expiring cells diff --git a/test/lib/simple_schema.hh b/test/lib/simple_schema.hh index 0da85a24e0..0a973d9e62 100644 --- a/test/lib/simple_schema.hh +++ b/test/lib/simple_schema.hh @@ -154,8 +154,7 @@ public: cmd.cells.emplace_back(k, atomic_cell::make_live(*bytes_type, t, v, atomic_cell::collection_member::yes)); } - const auto map_type = get_collection_type(); - auto serialized_map = cmd.serialize(*map_type); + auto serialized_map = cmd.serialize(); const column_definition& c1_def = *_s->get_column_definition(to_bytes("c1")); m.set_clustered_cell(ck, c1_def, atomic_cell_or_collection(std::move(serialized_map))); return t; diff --git a/tools/lua_sstable_consumer.cc b/tools/lua_sstable_consumer.cc index 168d6f2816..b9567b7c7d 100644 --- a/tools/lua_sstable_consumer.cc +++ b/tools/lua_sstable_consumer.cc @@ -742,7 +742,7 @@ struct collection_with_type { collection_mutation data; data_type type; - collection_with_type(collection_mutation_view data_view, data_type type) : data(*type, data_view), type(std::move(type)) { } + collection_with_type(collection_mutation_view data_view, data_type type) : data(data_view), type(std::move(type)) { } }; int collection_index_l(lua_State* l) {