mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-02 14:15:46 +00:00
A sequel to #7692. This series gets rid of linearization in `serialize_for_cql`, which serializes collections and user types from `collection_mutation_view` to CQL. We switch from `bytes` to `bytes_ostream` as the intermediate buffer type. The only user of of `serialize_for_cql` immediately copies the result to another `bytes_ostream`. We could avoid some copies and allocations by writing to the final `bytes_ostream` directly, but it's currently hidden behind a template. Before this series, `serialize_for_cql_aux()` delegated the actual writing to `collection_type_impl::pack` and `tuple_type_impl::build_value`, by passing them an intermediate `vector`. After this patch, the writing is done directly in `serialize_for_cql_aux()`. Pros: we avoid the overhead of creating an intermediate vector, without bloating the source code (because creating that intermediate vector requires just as much code as serializing the values right away). Cons: we duplicate the CQL collection format knowledge contained in `collection_type_impl::pack` and `tuple_type_impl::build_value`. Refs: #6138 Closes #7771 * github.com:scylladb/scylla: types: switch serialize_for_cql from bytes to bytes_ostream types: switch serialize_for_cql_aux from bytes to bytes_ostream types: serialize user types to bytes_ostream types: serialize lists to bytes_ostream types: serialize sets to bytes_ostream types: serialize maps to bytes_ostream utils: fragment_range: use range-based for loop instead of boost::for_each types: add write_collection_value() overload for bytes_ostream and value_view