mutation_partition: add row::with_both_ranges()

Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
This commit is contained in:
Paweł Dziepak
2015-10-22 11:56:55 +02:00
parent 1c05d7b927
commit a064181d7c
2 changed files with 22 additions and 13 deletions

View File

@@ -834,6 +834,23 @@ void row::reserve(column_id last_column)
}
}
template<typename Func>
auto row::with_both_ranges(const row& other, Func&& func) const {
if (_type == storage_type::vector) {
if (other._type == storage_type::vector) {
return func(get_range_vector(), other.get_range_vector());
} else {
return func(get_range_vector(), other.get_range_set());
}
} else {
if (other._type == storage_type::vector) {
return func(get_range_set(), other.get_range_vector());
} else {
return func(get_range_set(), other.get_range_set());
}
}
}
bool row::operator==(const row& other) const {
if (size() != other.size()) {
return false;
@@ -842,19 +859,9 @@ bool row::operator==(const row& other) const {
auto cells_equal = [] (std::pair<column_id, const atomic_cell_or_collection&> c1, std::pair<column_id, const atomic_cell_or_collection&> c2) {
return c1.first == c2.first && c1.second == c2.second;
};
if (_type == storage_type::vector) {
if (other._type == storage_type::vector) {
return boost::equal(get_range_vector(), other.get_range_vector(), cells_equal);
} else {
return boost::equal(get_range_vector(), other.get_range_set(), cells_equal);
}
} else {
if (other._type == storage_type::vector) {
return boost::equal(get_range_set(), other.get_range_vector(), cells_equal);
} else {
return boost::equal(get_range_set(), other.get_range_set(), cells_equal);
}
}
return with_both_ranges(other, [&] (auto r1, auto r2) {
return boost::equal(r1, r2, cells_equal);
});
}
row::row() {

View File

@@ -156,6 +156,8 @@ private:
return std::pair<column_id, const atomic_cell_or_collection&>(c.id(), c.cell());
});
}
template<typename Func>
auto with_both_ranges(const row& other, Func&& func) const;
void vector_to_set();
public: