From e8b50223432db54eefbf021f82219f8f4fa11e6f Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 13 Apr 2023 11:43:22 +0300 Subject: [PATCH] view: Keep backing-seconday-index bool on value_getter The getter needs to check if the view is backing a secondary index. Currentl it's done inside the handle_computed_column() method, but it's more convenient if this bit is known during construction, so move it there. There are no places that can change this property between view_getter is created and the method in question is called. Signed-off-by: Pavel Emelyanov --- db/view/view.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/view/view.cc b/db/view/view.cc index f4e344cdd0..545561c00d 100644 --- a/db/view/view.cc +++ b/db/view/view.cc @@ -571,6 +571,7 @@ private: const partition_key& _base_key; const clustering_or_static_row& _update; const std::optional& _existing; + 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& existing) @@ -579,6 +580,7 @@ public: , _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)) {} using vector_type = utils::small_vector; @@ -614,7 +616,7 @@ private: if (!cdef.is_computed()) { //FIXME(sarna): this legacy code is here for backward compatibility and should be removed // once "computed_columns feature" is supported by every node - if (!service::get_local_storage_proxy().local_db().find_column_family(_base.id()).get_index_manager().is_index(*_view)) { + if (!_backing_secondary_index) { throw std::logic_error(format("Column {} doesn't exist in base and this view is not backing a secondary index", cdef.name_as_text())); } computed_value = legacy_token_column_computation().compute_value(_base, _base_key);