mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
collection_mutation: move collection_type_impl::difference to collection_mutation.hh.
This commit is contained in:
@@ -261,14 +261,18 @@ collection_mutation merge(const abstract_type& type, collection_mutation_view a,
|
||||
});
|
||||
}
|
||||
|
||||
collection_mutation
|
||||
collection_type_impl::difference(collection_mutation_view a, collection_mutation_view b) const
|
||||
collection_mutation difference(const abstract_type& type, collection_mutation_view a, collection_mutation_view b)
|
||||
{
|
||||
return a.with_deserialized(*this, [&] (collection_mutation_view_description a_view) {
|
||||
return b.with_deserialized(*this, [&] (collection_mutation_view_description b_view) {
|
||||
return a.with_deserialized(type, [&] (collection_mutation_view_description a_view) {
|
||||
return b.with_deserialized(type, [&] (collection_mutation_view_description b_view) {
|
||||
assert(type.is_collection());
|
||||
auto& ctype = static_cast<const collection_type_impl&>(type);
|
||||
|
||||
collection_mutation_view_description diff;
|
||||
diff.cells.reserve(std::max(a_view.cells.size(), b_view.cells.size()));
|
||||
auto key_type = name_comparator();
|
||||
|
||||
auto key_type = ctype.name_comparator();
|
||||
|
||||
auto it = b_view.cells.begin();
|
||||
for (auto&& c : a_view.cells) {
|
||||
while (it != b_view.cells.end() && key_type->less(it->first, c.first)) {
|
||||
@@ -284,7 +288,7 @@ collection_type_impl::difference(collection_mutation_view a, collection_mutation
|
||||
if (a_view.tomb > b_view.tomb) {
|
||||
diff.tomb = a_view.tomb;
|
||||
}
|
||||
return diff.serialize(*this);
|
||||
return diff.serialize(type);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -111,3 +111,5 @@ public:
|
||||
};
|
||||
|
||||
collection_mutation merge(const abstract_type&, collection_mutation_view, collection_mutation_view);
|
||||
|
||||
collection_mutation difference(const abstract_type&, collection_mutation_view, collection_mutation_view);
|
||||
|
||||
@@ -1835,8 +1835,8 @@ row row::difference(const schema& s, column_kind kind, const row& other) const
|
||||
r.append_cell(c.first, c.second.copy(*cdef.type));
|
||||
}
|
||||
} else {
|
||||
auto ct = static_pointer_cast<const collection_type_impl>(s.column_at(kind, c.first).type);
|
||||
auto diff = ct->difference(c.second.as_collection_mutation(), it->second.as_collection_mutation());
|
||||
auto diff = ::difference(*s.column_at(kind, c.first).type,
|
||||
c.second.as_collection_mutation(), it->second.as_collection_mutation());
|
||||
if (!static_cast<collection_mutation_view>(diff).is_empty()) {
|
||||
r.append_cell(c.first, std::move(diff));
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ public:
|
||||
static bytes pack(BytesViewIterator start, BytesViewIterator finish, int elements, cql_serialization_format sf);
|
||||
virtual bytes to_value(collection_mutation_view_description mut, cql_serialization_format sf) const = 0;
|
||||
bytes to_value(collection_mutation_view mut, cql_serialization_format sf) const;
|
||||
collection_mutation difference(collection_mutation_view a, collection_mutation_view b) const;
|
||||
virtual void serialize(const void* value, bytes::iterator& out, cql_serialization_format sf) const = 0;
|
||||
virtual data_value deserialize(bytes_view v, cql_serialization_format sf) const = 0;
|
||||
data_value deserialize_value(bytes_view v, cql_serialization_format sf) const {
|
||||
|
||||
Reference in New Issue
Block a user