mutation_partition: Use rows_entry::position() in comparators

key() will not be valid for dummy entries, but position() is always
valid.

[tgrabiec: Extracted from other commits]
[tgrabiec: Added missing change to range_tombstone_stream::get_next]
This commit is contained in:
Piotr Jastrzebski
2017-05-19 15:48:05 +02:00
committed by Tomasz Grabiec
parent 660f3127a6
commit 65b3123516
3 changed files with 23 additions and 10 deletions

View File

@@ -917,7 +917,8 @@ position_in_partition_view rows_entry::position() const {
bool
rows_entry::equal(const schema& s, const rows_entry& other, const schema& other_schema) const {
return key().equal(s, other.key()) // Only representation-compatible changes are allowed
position_in_partition::equal_compare eq(s);
return eq(position(), other.position())
&& row().equal(column_kind::regular_column, s, other.row(), other_schema);
}

View File

@@ -689,23 +689,36 @@ public:
bool empty() const {
return _row.empty();
}
struct tri_compare {
position_in_partition::tri_compare _c;
explicit tri_compare(const schema& s) : _c(s) {}
int operator()(const rows_entry& e1, const rows_entry& e2) const {
return _c(e1.position(), e2.position());
}
int operator()(const clustering_key& key, const rows_entry& e) const {
return _c(position_in_partition_view::for_key(key), e.position());
}
int operator()(const rows_entry& e, const clustering_key& key) const {
return _c(e.position(), position_in_partition_view::for_key(key));
}
};
struct compare {
clustering_key::less_compare _c;
compare(const schema& s) : _c(s) {}
tri_compare _c;
explicit compare(const schema& s) : _c(s) {}
bool operator()(const rows_entry& e1, const rows_entry& e2) const {
return _c(e1._key, e2._key);
return _c(e1, e2) < 0;
}
bool operator()(const clustering_key& key, const rows_entry& e) const {
return _c(key, e._key);
return _c(key, e) < 0;
}
bool operator()(const rows_entry& e, const clustering_key& key) const {
return _c(e._key, key);
return _c(e, key) < 0;
}
bool operator()(const clustering_key_view& key, const rows_entry& e) const {
return _c(key, e._key);
return _c(key, e) < 0;
}
bool operator()(const rows_entry& e, const clustering_key_view& key) const {
return _c(e._key, key);
return _c(e, key) < 0;
}
};
template <typename Comparator>

View File

@@ -472,8 +472,7 @@ mutation_fragment_opt range_tombstone_stream::do_get_next()
mutation_fragment_opt range_tombstone_stream::get_next(const rows_entry& re)
{
if (!_list.empty()) {
position_in_partition_view view(position_in_partition_view::clustering_row_tag_t(), re.key());
return !_cmp(view, _list.begin()->position()) ? do_get_next() : mutation_fragment_opt();
return !_cmp(re.position(), _list.begin()->position()) ? do_get_next() : mutation_fragment_opt();
}
return { };
}