view_update_builder: Construct with data dictionary

The caller is table with view-update-generator at hand (it calls
mutate_MV on). Builder here is used as a temporary object that destroys
once the caller coroutine co_return-s, so keeping the database obtained
from the view-update-generator is safe.

Later the v.u.b. object will propagate its data dictionary down the
callstacks.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2023-04-19 21:49:52 +03:00
parent 4a16ab3bd4
commit 9d3d533561
3 changed files with 10 additions and 3 deletions

View File

@@ -1439,6 +1439,7 @@ future<stop_iteration> view_update_builder::on_results() {
}
view_update_builder make_view_update_builder(
data_dictionary::database db,
const replica::table& base_table,
const schema_ptr& base,
std::vector<view_and_base>&& views_to_update,
@@ -1454,7 +1455,7 @@ view_update_builder make_view_update_builder(
bool is_index = base_table.get_index_manager().is_index(v.view);
return view_updates(std::move(v), is_index);
}));
return view_update_builder(base_table, base, std::move(vs), std::move(updates), std::move(existings), now);
return view_update_builder(std::move(db), base_table, base, std::move(vs), std::move(updates), std::move(existings), now);
}
future<query::clustering_row_ranges> calculate_affected_clustering_ranges(const schema& base,

View File

@@ -14,6 +14,7 @@
#include "schema/schema_fwd.hh"
#include "readers/flat_mutation_reader_v2.hh"
#include "mutation/frozen_mutation.hh"
#include "data_dictionary/data_dictionary.hh"
class frozen_mutation_and_schema;
@@ -244,6 +245,7 @@ private:
};
class view_update_builder {
data_dictionary::database _db;
const replica::table& _base;
schema_ptr _schema; // The base schema
std::vector<view_updates> _view_updates;
@@ -259,12 +261,13 @@ class view_update_builder {
partition_key _key = partition_key::make_empty();
public:
view_update_builder(const replica::table& base, schema_ptr s,
view_update_builder(data_dictionary::database db, const replica::table& base, schema_ptr s,
std::vector<view_updates>&& views_to_update,
flat_mutation_reader_v2&& updates,
flat_mutation_reader_v2_opt&& existings,
gc_clock::time_point now)
: _base(base)
: _db(std::move(db))
, _base(base)
, _schema(std::move(s))
, _view_updates(std::move(views_to_update))
, _updates(std::move(updates))
@@ -298,6 +301,7 @@ private:
};
view_update_builder make_view_update_builder(
data_dictionary::database db,
const replica::table& base_table,
const schema_ptr& base_schema,
std::vector<view_and_base>&& views_to_update,

View File

@@ -2014,6 +2014,7 @@ future<> table::generate_and_propagate_view_updates(shared_ptr<db::view::view_up
auto base_token = m.token();
auto m_schema = m.schema();
db::view::view_update_builder builder = db::view::make_view_update_builder(
gen->get_db().as_data_dictionary(),
*this,
base,
std::move(views),
@@ -2151,6 +2152,7 @@ future<> table::populate_views(
gc_clock::time_point now) {
auto schema = reader.schema();
db::view::view_update_builder builder = db::view::make_view_update_builder(
gen->get_db().as_data_dictionary(),
*this,
schema,
std::move(views),