From ad7ab73cd035308fbea882dfd0236b93ad5d047b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Chojnowski?= Date: Mon, 23 Nov 2020 23:36:02 +0100 Subject: [PATCH] types: add FragmentedView versions of read_collection_size and read_collection_value We will need those to deserialize collections from FragmentedView. --- types.cc | 15 +++++++++++++++ types/list.hh | 1 + 2 files changed, 16 insertions(+) diff --git a/types.cc b/types.cc index a24358b0f1..24281d89cf 100644 --- a/types.cc +++ b/types.cc @@ -644,6 +644,15 @@ size_t collection_value_len(cql_serialization_format sf) { } +template +int read_collection_size(View& in, cql_serialization_format sf) { + if (sf.using_32_bits_for_collections()) { + return read_simple(in); + } else { + return read_simple(in); + } +} + int read_collection_size(bytes_view& in, cql_serialization_format sf) { if (sf.using_32_bits_for_collections()) { return read_simple(in); @@ -660,6 +669,12 @@ void write_collection_size(bytes::iterator& out, int size, cql_serialization_for } } +template +View read_collection_value(View& in, cql_serialization_format sf) { + auto size = sf.using_32_bits_for_collections() ? read_simple(in) : read_simple(in); + return read_simple_bytes(in, size); +} + bytes_view read_collection_value(bytes_view& in, cql_serialization_format sf) { auto size = sf.using_32_bits_for_collections() ? read_simple(in) : read_simple(in); return read_simple_bytes(in, size); diff --git a/types/list.hh b/types/list.hh index 04f7b7bd57..d03b4ebced 100644 --- a/types/list.hh +++ b/types/list.hh @@ -48,6 +48,7 @@ public: virtual bool is_value_compatible_with_frozen(const collection_type_impl& previous) const override; using abstract_type::deserialize; virtual data_value deserialize(bytes_view v, cql_serialization_format sf) const override; + template data_value deserialize(View v, cql_serialization_format sf) const; }; data_value make_list_value(data_type type, list_type_impl::native_type value);