From 3c601e578583720d7687ef1eb058b71007d010fa Mon Sep 17 00:00:00 2001 From: Hakob Saghatelyan Date: Wed, 11 May 2022 21:13:43 +0000 Subject: [PATCH] add Set support for ann_index_params setting --- src/Storages/MergeTree/CommonANNIndexes.cpp | 26 ++++----------------- src/Storages/MergeTree/CommonANNIndexes.h | 5 ---- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/Storages/MergeTree/CommonANNIndexes.cpp b/src/Storages/MergeTree/CommonANNIndexes.cpp index b7ccd320764..4e7246c48dd 100644 --- a/src/Storages/MergeTree/CommonANNIndexes.cpp +++ b/src/Storages/MergeTree/CommonANNIndexes.cpp @@ -5,6 +5,8 @@ #include #include +#include + #include namespace DB @@ -29,6 +31,8 @@ ANNCondition::ANNCondition(const SelectQueryInfo & query_info, buildRPN(query_info); // Match rpns with supported types index_is_useful = matchAllRPNS(); + // Get from settings ANNIndex parameters + ann_index_params = context->getSettings().get("ann_index_params").get(); } bool ANNCondition::alwaysUnknownOrTrue(String metric_name) const @@ -114,11 +118,6 @@ void ANNCondition::buildRPN(const SelectQueryInfo & query) traverseAST(select.limitLength(), rpn_limit_clause); } - if (select.settings()) // If query has SETTINGS section - { - parseSettings(select.settings()); - } - if (select.orderBy()) // If query has ORDERBY section { traverseOrderByAST(select.orderBy(), rpn_order_by_clause); @@ -200,7 +199,7 @@ bool ANNCondition::traverseAtomAST(const ASTPtr & node, RPNElement & out) // Check if we have constants behind the node return tryCastToConstType(node, out); - } +} bool ANNCondition::tryCastToConstType(const ASTPtr & node, RPNElement & out) { @@ -310,21 +309,6 @@ bool ANNCondition::matchRPNLimit(RPN & rpn, LimitExpression & expr) return false; } -void ANNCondition::parseSettings(const ASTPtr & node) -{ - if (const auto * set = node->as()) - { - for (const auto & change : set->changes) - { - if (change.name == "ann_index_params") - { - ann_index_params = change.value.get(); - return; - } - } - } -} - bool ANNCondition::matchRPNOrderBy(RPN & rpn, ANNExpression & expr) { // ORDERBY section must have at least 3 expressions diff --git a/src/Storages/MergeTree/CommonANNIndexes.h b/src/Storages/MergeTree/CommonANNIndexes.h index e14a659e41a..1ca4858a469 100644 --- a/src/Storages/MergeTree/CommonANNIndexes.h +++ b/src/Storages/MergeTree/CommonANNIndexes.h @@ -165,7 +165,6 @@ private: // Traverses the AST of ORDERBY section void traverseOrderByAST(const ASTPtr & node, RPN & rpn); - // Checks that at least one rpn is matching for index // New RPNs for other query types can be added here bool matchAllRPNS(); @@ -179,10 +178,6 @@ private: // Returns true and stores Length if we have valid LIMIT clause in query static bool matchRPNLimit(RPN & rpn, LimitExpression & expr); - // Parses SETTINGS section, stores the new value for 'ann_index_params' - void parseSettings(const ASTPtr & node); - - /* Matches dist function, target vector, column name */ static bool matchMainParts(RPN::iterator & iter, RPN::iterator & end, ANNExpression & expr, bool & identifier_found);