From ea26186043fc4d7fda65d0960756271e19947f08 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Thu, 28 Nov 2024 19:55:15 +0200 Subject: [PATCH] cql3: statement_restrictions: make get_multi_column_clustering_bounds a builder Lay the groundwork for analyzing multi column clustering bounds by splitting the function into prepare-time and execute-time parts. To start with, all of the work is done at query time, but later patches will move bits into prepare time. --- cql3/restrictions/statement_restrictions.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cql3/restrictions/statement_restrictions.cc b/cql3/restrictions/statement_restrictions.cc index 07aa8a527e..fcef330704 100644 --- a/cql3/restrictions/statement_restrictions.cc +++ b/cql3/restrictions/statement_restrictions.cc @@ -2370,11 +2370,12 @@ std::vector get_equivalent_ranges( const query::clustering_range& cql_order_range, const schema& schema); /// Calculates clustering bounds for the multi-column case. -std::vector get_multi_column_clustering_bounds( - const query_options& options, +std::function (const query_options&)> +build_get_multi_column_clustering_bounds_fn( schema_ptr schema, const std::vector& multi_column_restrictions, bool all_natural, bool all_reverse) { + return [schema, multi_column_restrictions, all_natural, all_reverse] (const query_options& options) -> std::vector { multi_column_range_accumulator acc{options, schema}; for (const auto& restr : multi_column_restrictions | std::views::transform(&predicate::filter)) { expr::visit(acc, restr); @@ -2395,6 +2396,7 @@ std::vector get_multi_column_clustering_bounds( } } return bounds; + }; } /// Reverses the range if the type is reversed. Why don't we have interval::reverse()?? @@ -2736,10 +2738,8 @@ statement_restrictions::build_get_clustering_bounds_fn() const { } } } - return [this, all_natural, all_reverse] (const query_options& options) -> std::vector { - return get_multi_column_clustering_bounds(options, _schema, _clustering_prefix_restrictions, + return build_get_multi_column_clustering_bounds_fn(_schema, _clustering_prefix_restrictions, all_natural, all_reverse); - }; } else { return [&] (const query_options& options) -> std::vector { return get_single_column_clustering_bounds(options, *_schema, _clustering_prefix_restrictions);