view: Carry backing-secondary-index bit via view builder
When view builder constructs it populates itself with view updates. Later the updates may instantiate the value_getter-s which, in turn, would need to check if the view is backing secondary index. Good news is that when view builder constructs it has all the information at hand needed to evaluate this "backing" bit. It's then propagated down to value_getter via corresponding view_updates. The getter's _view field becomes unused after this change and is (void)-ed to make this patch compile. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -574,14 +574,16 @@ private:
|
||||
const bool _backing_secondary_index;
|
||||
|
||||
public:
|
||||
value_getter(const schema& base, const view_ptr& view, const partition_key& base_key, const clustering_or_static_row& update, const std::optional<clustering_or_static_row>& existing)
|
||||
value_getter(const schema& base, const view_ptr& view, const partition_key& base_key, const clustering_or_static_row& update, const std::optional<clustering_or_static_row>& existing, bool backing_secondary_index)
|
||||
: _base(base)
|
||||
, _view(view)
|
||||
, _base_key(base_key)
|
||||
, _update(update)
|
||||
, _existing(existing)
|
||||
, _backing_secondary_index(service::get_local_storage_proxy().local_db().find_column_family(_base.id()).get_index_manager().is_index(*_view))
|
||||
{}
|
||||
, _backing_secondary_index(backing_secondary_index)
|
||||
{
|
||||
(void)_view;
|
||||
}
|
||||
|
||||
using vector_type = utils::small_vector<view_managed_key_view_and_action, 1>;
|
||||
vector_type operator()(const column_definition& cdef) {
|
||||
@@ -649,7 +651,7 @@ private:
|
||||
|
||||
std::vector<view_updates::view_row_entry>
|
||||
view_updates::get_view_rows(const partition_key& base_key, const clustering_or_static_row& update, const std::optional<clustering_or_static_row>& existing) {
|
||||
value_getter getter(*_base, _view, base_key, update, existing);
|
||||
value_getter getter(*_base, _view, base_key, update, existing, _backing_secondary_index);
|
||||
auto get_value = boost::adaptors::transformed(std::ref(getter));
|
||||
|
||||
|
||||
@@ -1452,7 +1454,8 @@ view_update_builder make_view_update_builder(
|
||||
" base schema version of the view ({}) for view {}.{} of {}.{}",
|
||||
base->version(), v.base->base_schema()->version(), v.view->ks_name(), v.view->cf_name(), base->ks_name(), base->cf_name()));
|
||||
}
|
||||
return view_updates(std::move(v));
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -209,13 +209,16 @@ class view_updates final {
|
||||
base_info_ptr _base_info;
|
||||
std::unordered_map<partition_key, mutation_partition, partition_key::hashing, partition_key::equality> _updates;
|
||||
mutable size_t _op_count = 0;
|
||||
const bool _backing_secondary_index;
|
||||
public:
|
||||
explicit view_updates(view_and_base vab)
|
||||
explicit view_updates(view_and_base vab, bool backing_secondary_index)
|
||||
: _view(std::move(vab.view))
|
||||
, _view_info(*_view->view_info())
|
||||
, _base(vab.base->base_schema())
|
||||
, _base_info(vab.base)
|
||||
, _updates(8, partition_key::hashing(*_view), partition_key::equality(*_view)) {
|
||||
, _updates(8, partition_key::hashing(*_view), partition_key::equality(*_view))
|
||||
, _backing_secondary_index(backing_secondary_index)
|
||||
{
|
||||
}
|
||||
|
||||
future<> move_to(utils::chunked_vector<frozen_mutation_and_schema>& mutations);
|
||||
|
||||
Reference in New Issue
Block a user