deletable_row: add column_kind parameter to is_live

While deletable_row is used to hold regular columns of a clustering row,
its name or implementation doesn't suggest that it is a requirement. In
fact, some of its methods already take a column_kind parameter which is
used to interpret the kind of columns held in the row.

This commit removes the assumption about the column kind from the
`deletable_row::is_live` method.
This commit is contained in:
Piotr Dulikowski
2022-09-07 15:49:00 +02:00
parent 27c81432cd
commit 05d4328f02
5 changed files with 7 additions and 7 deletions

View File

@@ -63,7 +63,7 @@ public:
bool empty() const { return _row.empty(); }
bool is_live(const schema& s, tombstone base_tombstone = tombstone(), gc_clock::time_point now = gc_clock::time_point::min()) const {
return _row.is_live(s, std::move(base_tombstone), std::move(now));
return _row.is_live(s, column_kind::regular_column, std::move(base_tombstone), std::move(now));
}
void apply(const schema& s, clustering_row&& cr) {

View File

@@ -1505,13 +1505,13 @@ bool mutation_partition::empty() const
}
bool
deletable_row::is_live(const schema& s, tombstone base_tombstone, gc_clock::time_point query_time) const {
deletable_row::is_live(const schema& s, column_kind kind, tombstone base_tombstone, gc_clock::time_point query_time) const {
// _created_at corresponds to the row marker cell, present for rows
// created with the 'insert' statement. If row marker is live, we know the
// row is live. Otherwise, a row is considered live if it has any cell
// which is live.
base_tombstone.apply(_deleted_at.tomb());
return _marker.is_live(base_tombstone, query_time) || _cells.is_live(s, column_kind::regular_column, base_tombstone, query_time);
return _marker.is_live(base_tombstone, query_time) || _cells.is_live(s, kind, base_tombstone, query_time);
}
bool
@@ -1532,7 +1532,7 @@ mutation_partition::live_row_count(const schema& s, gc_clock::time_point query_t
for (const rows_entry& e : non_dummy_rows()) {
tombstone base_tombstone = range_tombstone_for_row(s, e.key());
if (e.row().is_live(s, base_tombstone, query_time)) {
if (e.row().is_live(s, column_kind::regular_column, base_tombstone, query_time)) {
++count;
}
}

View File

@@ -866,7 +866,7 @@ public:
const row& cells() const { return _cells; }
row& cells() { return _cells; }
bool equal(column_kind, const schema& s, const deletable_row& other, const schema& other_schema) const;
bool is_live(const schema& s, tombstone base_tombstone = tombstone(), gc_clock::time_point query_time = gc_clock::time_point::min()) const;
bool is_live(const schema& s, column_kind kind, tombstone base_tombstone = tombstone(), gc_clock::time_point query_time = gc_clock::time_point::min()) const;
bool empty() const { return !_deleted_at && _marker.is_missing() && !_cells.size(); }
deletable_row difference(const schema&, column_kind, const deletable_row& other) const;

View File

@@ -1115,7 +1115,7 @@ static void validate_result(size_t i, const mutation& result_mut, const expected
const auto exp_dead_end = expected_part.dead_rows.cend();
for (; res_it != res_end && (exp_live_it != exp_live_end || exp_dead_it != exp_dead_end); ++res_it) {
const bool is_live = res_it->row().is_live(schema);
const bool is_live = res_it->row().is_live(schema, column_kind::regular_column);
// Check that we have remaining expected rows of the respective liveness.
if (is_live) {

View File

@@ -3180,7 +3180,7 @@ SEASTAR_TEST_CASE(compact_deleted_cell) {
auto rows = m->partition().clustered_rows();
BOOST_REQUIRE(rows.calculate_size() == 1);
auto& row = rows.begin()->row();
BOOST_REQUIRE(row.is_live(*s));
BOOST_REQUIRE(row.is_live(*s, column_kind::regular_column));
auto& cells = row.cells();
BOOST_REQUIRE(cells.size() == 1);
});