mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
types: add FragmentedView versions of read_collection_size and read_collection_value
We will need those to deserialize collections from FragmentedView.
This commit is contained in:
15
types.cc
15
types.cc
@@ -644,6 +644,15 @@ size_t collection_value_len(cql_serialization_format sf) {
|
||||
}
|
||||
|
||||
|
||||
template <FragmentedView View>
|
||||
int read_collection_size(View& in, cql_serialization_format sf) {
|
||||
if (sf.using_32_bits_for_collections()) {
|
||||
return read_simple<int32_t>(in);
|
||||
} else {
|
||||
return read_simple<uint16_t>(in);
|
||||
}
|
||||
}
|
||||
|
||||
int read_collection_size(bytes_view& in, cql_serialization_format sf) {
|
||||
if (sf.using_32_bits_for_collections()) {
|
||||
return read_simple<int32_t>(in);
|
||||
@@ -660,6 +669,12 @@ void write_collection_size(bytes::iterator& out, int size, cql_serialization_for
|
||||
}
|
||||
}
|
||||
|
||||
template <FragmentedView View>
|
||||
View read_collection_value(View& in, cql_serialization_format sf) {
|
||||
auto size = sf.using_32_bits_for_collections() ? read_simple<int32_t>(in) : read_simple<uint16_t>(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<int32_t>(in) : read_simple<uint16_t>(in);
|
||||
return read_simple_bytes(in, size);
|
||||
|
||||
@@ -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 <FragmentedView View> data_value deserialize(View v, cql_serialization_format sf) const;
|
||||
};
|
||||
|
||||
data_value make_list_value(data_type type, list_type_impl::native_type value);
|
||||
|
||||
Reference in New Issue
Block a user