From 9c96d74b7240fd9087792510d7c054594a5adeea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Mon, 18 Jan 2021 14:25:11 +0200 Subject: [PATCH] mutation: remove now unused query() and query_compacted() --- mutation.cc | 35 ----------------- mutation.hh | 21 ----------- mutation_partition.cc | 88 ------------------------------------------- mutation_partition.hh | 5 --- 4 files changed, 149 deletions(-) diff --git a/mutation.cc b/mutation.cc index 4dc67e5e76..e025c67d5d 100644 --- a/mutation.cc +++ b/mutation.cc @@ -105,41 +105,6 @@ bool mutation::operator!=(const mutation& m) const { return !(*this == m); } -void -mutation::query(query::result::builder& builder, - const query::partition_slice& slice, - gc_clock::time_point now, - uint64_t row_limit) && -{ - auto pb = builder.add_partition(*schema(), key()); - auto is_reversed = slice.options.contains(); - auto always_return_static_content = slice.options.contains(); - mutation_partition& p = partition(); - auto limit = std::min(row_limit, slice.partition_row_limit()); - p.compact_for_query(*schema(), now, slice.row_ranges(*schema(), key()), always_return_static_content, is_reversed, limit); - p.query_compacted(pb, *schema(), limit); -} - -query::result -mutation::query(const query::partition_slice& slice, - query::result_memory_accounter&& accounter, - query::result_options opts, - gc_clock::time_point now, uint64_t row_limit) && -{ - query::result::builder builder(slice, opts, std::move(accounter)); - std::move(*this).query(builder, slice, now, row_limit); - return builder.build(); -} - -query::result -mutation::query(const query::partition_slice& slice, - query::result_memory_accounter&& accounter, - query::result_options opts, - gc_clock::time_point now, uint64_t row_limit) const& -{ - return mutation(*this).query(slice, std::move(accounter), opts, now, row_limit); -} - uint64_t mutation::live_row_count(gc_clock::time_point query_time) const { return partition().live_row_count(*schema(), query_time); diff --git a/mutation.hh b/mutation.hh index e3436d8d71..0862ffdd69 100644 --- a/mutation.hh +++ b/mutation.hh @@ -119,27 +119,6 @@ public: bool operator==(const mutation&) const; bool operator!=(const mutation&) const; public: - // The supplied partition_slice must be governed by this mutation's schema - query::result query(const query::partition_slice&, - query::result_memory_accounter&& accounter, - query::result_options opts = query::result_options::only_result(), - gc_clock::time_point now = gc_clock::now(), - uint64_t row_limit = query::max_rows) &&; - - // The supplied partition_slice must be governed by this mutation's schema - // FIXME: Slower than the r-value version - query::result query(const query::partition_slice&, - query::result_memory_accounter&& accounter, - query::result_options opts = query::result_options::only_result(), - gc_clock::time_point now = gc_clock::now(), - uint64_t row_limit = query::max_rows) const&; - - // The supplied partition_slice must be governed by this mutation's schema - void query(query::result::builder& builder, - const query::partition_slice& slice, - gc_clock::time_point now = gc_clock::now(), - uint64_t row_limit = query::max_rows) &&; - // Consumes the mutation's content. // // The mutation is in a moved-from alike state after consumption. diff --git a/mutation_partition.cc b/mutation_partition.cc index 6edf60d548..bc9de2188e 100644 --- a/mutation_partition.cc +++ b/mutation_partition.cc @@ -908,94 +908,6 @@ bool has_any_live_data(const schema& s, column_kind kind, const row& cells, tomb return any_live; } -void -mutation_partition::query_compacted(query::result::partition_writer& pw, const schema& s, uint64_t limit) const { - check_schema(s); - const query::partition_slice& slice = pw.slice(); - max_timestamp max_ts{pw.last_modified()}; - - if (limit == 0) { - pw.retract(); - return; - } - - auto static_cells_wr = pw.start().start_static_row().start_cells(); - - if (!slice.static_columns.empty()) { - if (pw.requested_result()) { - get_compacted_row_slice(s, slice, column_kind::static_column, static_row().get(), slice.static_columns, static_cells_wr); - } - if (pw.requested_digest()) { - auto pt = partition_tombstone(); - pw.digest().feed_hash(pt); - max_ts.update(pt.timestamp); - pw.digest().feed_hash(static_row().get(), s, column_kind::static_column, slice.static_columns, max_ts); - } - } - - auto rows_wr = std::move(static_cells_wr).end_cells() - .end_static_row() - .start_rows(); - - uint64_t row_count = 0; - - auto is_reversed = slice.options.contains(query::partition_slice::option::reversed); - auto send_ck = slice.options.contains(query::partition_slice::option::send_clustering_key); - for_each_row(s, query::clustering_range::make_open_ended_both_sides(), is_reversed, [&] (const rows_entry& e) { - if (e.dummy()) { - return stop_iteration::no; - } - auto& row = e.row(); - auto row_tombstone = tombstone_for_row(s, e); - - if (pw.requested_digest()) { - pw.digest().feed_hash(e.key(), s); - pw.digest().feed_hash(row_tombstone); - max_ts.update(row_tombstone.tomb().timestamp); - pw.digest().feed_hash(row.cells(), s, column_kind::regular_column, slice.regular_columns, max_ts); - } - - if (row.is_live(s)) { - if (pw.requested_result()) { - auto cells_wr = [&] { - if (send_ck) { - return rows_wr.add().write_key(e.key()).start_cells().start_cells(); - } else { - return rows_wr.add().skip_key().start_cells().start_cells(); - } - }(); - get_compacted_row_slice(s, slice, column_kind::regular_column, row.cells(), slice.regular_columns, cells_wr); - std::move(cells_wr).end_cells().end_cells().end_qr_clustered_row(); - } - ++row_count; - if (--limit == 0) { - return stop_iteration::yes; - } - } - return stop_iteration::no; - }); - - pw.last_modified() = max_ts.max; - - // If we got no rows, but have live static columns, we should only - // give them back IFF we did not have any CK restrictions. - // #589 - // If ck:s exist, and we do a restriction on them, we either have maching - // rows, or return nothing, since cql does not allow "is null". - bool return_static_content_on_partition_with_no_rows = - pw.slice().options.contains(query::partition_slice::option::always_return_static_content) || - !has_ck_selector(pw.ranges()); - if (row_count == 0 - && (!return_static_content_on_partition_with_no_rows - || !has_any_live_data(s, column_kind::static_column, static_row().get()))) { - pw.retract(); - } else { - pw.row_count() += row_count ? : 1; - pw.partition_count() += 1; - std::move(rows_wr).end_rows().end_qr_partition(); - } -} - std::ostream& operator<<(std::ostream& os, const std::pair& c) { return fmt_print(os, "{{column: {} {}}}", c.first, c.second); diff --git a/mutation_partition.hh b/mutation_partition.hh index 88e3e0af48..bb0ef14c78 100644 --- a/mutation_partition.hh +++ b/mutation_partition.hh @@ -1479,11 +1479,6 @@ public: return boost::make_iterator_range(_rows.begin(), _rows.end()) | boost::adaptors::filtered([] (const rows_entry& e) { return bool(!e.dummy()); }); } - // Writes this partition using supplied query result writer. - // The partition should be first compacted with compact_for_query(), otherwise - // results may include data which is deleted/expired. - // At most row_limit CQL rows will be written and digested. - void query_compacted(query::result::partition_writer& pw, const schema& s, uint64_t row_limit) const; void accept(const schema&, mutation_partition_visitor&) const; // Returns the number of live CQL rows in this partition.