collection_type_impl: add to_value(mutation_view)
Allows collapsing a mutation into a literal.
This commit is contained in:
36
types.cc
36
types.cc
@@ -825,6 +825,18 @@ map_type_impl::serialized_values(std::vector<atomic_cell::one> cells) {
|
||||
abort();
|
||||
}
|
||||
|
||||
bytes
|
||||
map_type_impl::to_value(mutation_view mut, int protocol_version) {
|
||||
std::vector<bytes_view> tmp;
|
||||
tmp.reserve(mut.size() * 2);
|
||||
for (auto&& e : mut) {
|
||||
if (e.second.is_live()) {
|
||||
tmp.emplace_back(e.first);
|
||||
tmp.emplace_back(e.second.value());
|
||||
}
|
||||
}
|
||||
return pack(tmp.begin(), tmp.end(), tmp.size() / 2, protocol_version);
|
||||
}
|
||||
|
||||
bytes
|
||||
map_type_impl::serialize_partially_deserialized_form(
|
||||
@@ -1084,6 +1096,18 @@ set_type_impl::serialized_values(std::vector<atomic_cell::one> cells) {
|
||||
abort();
|
||||
}
|
||||
|
||||
bytes
|
||||
set_type_impl::to_value(mutation_view mut, int protocol_version) {
|
||||
std::vector<bytes_view> tmp;
|
||||
tmp.reserve(mut.size());
|
||||
for (auto&& e : mut) {
|
||||
if (e.second.is_live()) {
|
||||
tmp.emplace_back(e.first);
|
||||
}
|
||||
}
|
||||
return pack(tmp.begin(), tmp.end(), tmp.size(), protocol_version);
|
||||
}
|
||||
|
||||
list_type
|
||||
list_type_impl::get_instance(data_type elements, bool is_multi_cell) {
|
||||
return intern::get_instance(elements, is_multi_cell);
|
||||
@@ -1211,6 +1235,18 @@ list_type_impl::serialized_values(std::vector<atomic_cell::one> cells) {
|
||||
abort();
|
||||
}
|
||||
|
||||
bytes
|
||||
list_type_impl::to_value(mutation_view mut, int protocol_version) {
|
||||
std::vector<bytes_view> tmp;
|
||||
tmp.reserve(mut.size());
|
||||
for (auto&& e : mut) {
|
||||
if (e.second.is_live()) {
|
||||
tmp.emplace_back(e.second.value());
|
||||
}
|
||||
}
|
||||
return pack(tmp.begin(), tmp.end(), tmp.size(), protocol_version);
|
||||
}
|
||||
|
||||
thread_local const shared_ptr<abstract_type> int32_type(make_shared<int32_type_impl>());
|
||||
thread_local const shared_ptr<abstract_type> long_type(make_shared<long_type_impl>());
|
||||
thread_local const shared_ptr<abstract_type> ascii_type(make_shared<string_type_impl>("ascii", cql3::native_cql3_type::ascii));
|
||||
|
||||
4
types.hh
4
types.hh
@@ -203,6 +203,7 @@ public:
|
||||
template <typename BytesViewIterator>
|
||||
static bytes pack(BytesViewIterator start, BytesViewIterator finish, int elements, int version);
|
||||
mutation_view deserialize_mutation_form(bytes_view in);
|
||||
virtual bytes to_value(mutation_view mut, int protocol_version) = 0;
|
||||
// FIXME: use iterators?
|
||||
collection_mutation::one serialize_mutation_form(const mutation& mut);
|
||||
collection_mutation::one serialize_mutation_form(mutation_view mut);
|
||||
@@ -290,6 +291,7 @@ public:
|
||||
virtual std::vector<bytes> serialized_values(std::vector<atomic_cell::one> cells) override;
|
||||
static bytes serialize_partially_deserialized_form(const std::vector<std::pair<bytes_view, bytes_view>>& v,
|
||||
int protocol_version);
|
||||
virtual bytes to_value(mutation_view mut, int protocol_version) override;
|
||||
};
|
||||
|
||||
using map_type = shared_ptr<map_type_impl>;
|
||||
@@ -322,6 +324,7 @@ public:
|
||||
virtual size_t hash(bytes_view v) override;
|
||||
virtual bytes from_string(sstring_view text) override;
|
||||
virtual std::vector<bytes> serialized_values(std::vector<atomic_cell::one> cells) override;
|
||||
virtual bytes to_value(mutation_view mut, int protocol_version) override;
|
||||
};
|
||||
|
||||
using set_type = shared_ptr<set_type_impl>;
|
||||
@@ -354,6 +357,7 @@ public:
|
||||
virtual size_t hash(bytes_view v) override;
|
||||
virtual bytes from_string(sstring_view text) override;
|
||||
virtual std::vector<bytes> serialized_values(std::vector<atomic_cell::one> cells) override;
|
||||
virtual bytes to_value(mutation_view mut, int protocol_version) override;
|
||||
};
|
||||
|
||||
using list_type = shared_ptr<list_type_impl>;
|
||||
|
||||
Reference in New Issue
Block a user