From e493789bf346d4521391de925f39b9da0d929866 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Wed, 27 Dec 2023 17:51:23 +0000 Subject: [PATCH] Remove from indexes as well. --- src/Storages/MergeTree/MergeTreeIndexAnnoy.h | 2 -- .../MergeTree/MergeTreeIndexBloomFilter.cpp | 27 ------------------- .../MergeTree/MergeTreeIndexBloomFilter.h | 2 -- .../MergeTree/MergeTreeIndexFullText.cpp | 5 ---- .../MergeTree/MergeTreeIndexFullText.h | 2 -- .../MergeTree/MergeTreeIndexHypothesis.cpp | 5 ---- .../MergeTree/MergeTreeIndexHypothesis.h | 2 -- .../MergeTree/MergeTreeIndexInverted.cpp | 5 ---- .../MergeTree/MergeTreeIndexInverted.h | 2 -- .../MergeTree/MergeTreeIndexMinMax.cpp | 15 ----------- src/Storages/MergeTree/MergeTreeIndexMinMax.h | 2 -- src/Storages/MergeTree/MergeTreeIndexSet.cpp | 5 ---- src/Storages/MergeTree/MergeTreeIndexSet.h | 2 -- .../MergeTree/MergeTreeIndexUSearch.h | 2 -- src/Storages/MergeTree/MergeTreeIndices.h | 3 --- 15 files changed, 81 deletions(-) diff --git a/src/Storages/MergeTree/MergeTreeIndexAnnoy.h b/src/Storages/MergeTree/MergeTreeIndexAnnoy.h index 1e753fd9bc4..dead12fe66f 100644 --- a/src/Storages/MergeTree/MergeTreeIndexAnnoy.h +++ b/src/Storages/MergeTree/MergeTreeIndexAnnoy.h @@ -100,8 +100,6 @@ public: MergeTreeIndexAggregatorPtr createIndexAggregator(const MergeTreeWriterSettings & settings) const override; MergeTreeIndexConditionPtr createIndexCondition(const SelectQueryInfo & query, ContextPtr context) const override; - bool mayBenefitFromIndexForIn(const ASTPtr & /*node*/) const override { return false; } - private: const UInt64 trees; const String distance_function; diff --git a/src/Storages/MergeTree/MergeTreeIndexBloomFilter.cpp b/src/Storages/MergeTree/MergeTreeIndexBloomFilter.cpp index ea3f4eac090..fa05f9e61e1 100644 --- a/src/Storages/MergeTree/MergeTreeIndexBloomFilter.cpp +++ b/src/Storages/MergeTree/MergeTreeIndexBloomFilter.cpp @@ -38,33 +38,6 @@ MergeTreeIndexGranulePtr MergeTreeIndexBloomFilter::createIndexGranule() const return std::make_shared(bits_per_row, hash_functions, index.column_names.size()); } -bool MergeTreeIndexBloomFilter::mayBenefitFromIndexForIn(const ASTPtr & node) const -{ - Names required_columns = index.expression->getRequiredColumns(); - NameSet required_columns_set(required_columns.begin(), required_columns.end()); - - std::vector nodes_to_check; - nodes_to_check.emplace_back(node); - - while (!nodes_to_check.empty()) - { - auto node_to_check = nodes_to_check.back(); - nodes_to_check.pop_back(); - - const auto & column_name = node_to_check->getColumnName(); - if (required_columns_set.find(column_name) != required_columns_set.end()) - return true; - - if (const auto * function = typeid_cast(node_to_check.get())) - { - auto & function_arguments_children = function->arguments->children; - nodes_to_check.insert(nodes_to_check.end(), function_arguments_children.begin(), function_arguments_children.end()); - } - } - - return false; -} - MergeTreeIndexAggregatorPtr MergeTreeIndexBloomFilter::createIndexAggregator(const MergeTreeWriterSettings & /*settings*/) const { return std::make_shared(bits_per_row, hash_functions, index.column_names); diff --git a/src/Storages/MergeTree/MergeTreeIndexBloomFilter.h b/src/Storages/MergeTree/MergeTreeIndexBloomFilter.h index f60630c8056..4d688ae3cfc 100644 --- a/src/Storages/MergeTree/MergeTreeIndexBloomFilter.h +++ b/src/Storages/MergeTree/MergeTreeIndexBloomFilter.h @@ -22,8 +22,6 @@ public: MergeTreeIndexConditionPtr createIndexCondition(const SelectQueryInfo & query_info, ContextPtr context) const override; - bool mayBenefitFromIndexForIn(const ASTPtr & node) const override; - private: size_t bits_per_row; size_t hash_functions; diff --git a/src/Storages/MergeTree/MergeTreeIndexFullText.cpp b/src/Storages/MergeTree/MergeTreeIndexFullText.cpp index cf8cd1ffba4..6c1fff53109 100644 --- a/src/Storages/MergeTree/MergeTreeIndexFullText.cpp +++ b/src/Storages/MergeTree/MergeTreeIndexFullText.cpp @@ -696,11 +696,6 @@ MergeTreeIndexConditionPtr MergeTreeIndexFullText::createIndexCondition( return std::make_shared(query, context, index.sample_block, params, token_extractor.get()); } -bool MergeTreeIndexFullText::mayBenefitFromIndexForIn(const ASTPtr & node) const -{ - return std::find(std::cbegin(index.column_names), std::cend(index.column_names), node->getColumnName()) != std::cend(index.column_names); -} - MergeTreeIndexPtr bloomFilterIndexCreator( const IndexDescription & index) { diff --git a/src/Storages/MergeTree/MergeTreeIndexFullText.h b/src/Storages/MergeTree/MergeTreeIndexFullText.h index e4e9a670046..22f9215d563 100644 --- a/src/Storages/MergeTree/MergeTreeIndexFullText.h +++ b/src/Storages/MergeTree/MergeTreeIndexFullText.h @@ -167,8 +167,6 @@ public: MergeTreeIndexConditionPtr createIndexCondition( const SelectQueryInfo & query, ContextPtr context) const override; - bool mayBenefitFromIndexForIn(const ASTPtr & node) const override; - BloomFilterParameters params; /// Function for selecting next token. std::unique_ptr token_extractor; diff --git a/src/Storages/MergeTree/MergeTreeIndexHypothesis.cpp b/src/Storages/MergeTree/MergeTreeIndexHypothesis.cpp index f5136cc3764..818bae40067 100644 --- a/src/Storages/MergeTree/MergeTreeIndexHypothesis.cpp +++ b/src/Storages/MergeTree/MergeTreeIndexHypothesis.cpp @@ -91,11 +91,6 @@ MergeTreeIndexMergedConditionPtr MergeTreeIndexHypothesis::createIndexMergedCond query_info, storage_metadata->getConstraints(), index.granularity); } -bool MergeTreeIndexHypothesis::mayBenefitFromIndexForIn(const ASTPtr &) const -{ - return false; -} - MergeTreeIndexPtr hypothesisIndexCreator(const IndexDescription & index) { return std::make_shared(index); diff --git a/src/Storages/MergeTree/MergeTreeIndexHypothesis.h b/src/Storages/MergeTree/MergeTreeIndexHypothesis.h index e138559a1d0..1cd0e3daf27 100644 --- a/src/Storages/MergeTree/MergeTreeIndexHypothesis.h +++ b/src/Storages/MergeTree/MergeTreeIndexHypothesis.h @@ -75,8 +75,6 @@ public: MergeTreeIndexMergedConditionPtr createIndexMergedCondition( const SelectQueryInfo & query_info, StorageMetadataPtr storage_metadata) const override; - bool mayBenefitFromIndexForIn(const ASTPtr & node) const override; - size_t max_rows = 0; }; diff --git a/src/Storages/MergeTree/MergeTreeIndexInverted.cpp b/src/Storages/MergeTree/MergeTreeIndexInverted.cpp index 908fc98728e..5e2a034cb97 100644 --- a/src/Storages/MergeTree/MergeTreeIndexInverted.cpp +++ b/src/Storages/MergeTree/MergeTreeIndexInverted.cpp @@ -726,11 +726,6 @@ MergeTreeIndexConditionPtr MergeTreeIndexInverted::createIndexCondition( return std::make_shared(query, context, index.sample_block, params, token_extractor.get()); }; -bool MergeTreeIndexInverted::mayBenefitFromIndexForIn(const ASTPtr & node) const -{ - return std::find(std::cbegin(index.column_names), std::cend(index.column_names), node->getColumnName()) != std::cend(index.column_names); -} - MergeTreeIndexPtr invertedIndexCreator( const IndexDescription & index) { diff --git a/src/Storages/MergeTree/MergeTreeIndexInverted.h b/src/Storages/MergeTree/MergeTreeIndexInverted.h index 86bf7613646..413cf206f0e 100644 --- a/src/Storages/MergeTree/MergeTreeIndexInverted.h +++ b/src/Storages/MergeTree/MergeTreeIndexInverted.h @@ -171,8 +171,6 @@ public: MergeTreeIndexAggregatorPtr createIndexAggregatorForPart(const GinIndexStorePtr & store, const MergeTreeWriterSettings & /*settings*/) const override; MergeTreeIndexConditionPtr createIndexCondition(const SelectQueryInfo & query, ContextPtr context) const override; - bool mayBenefitFromIndexForIn(const ASTPtr & node) const override; - GinFilterParameters params; /// Function for selecting next token. std::unique_ptr token_extractor; diff --git a/src/Storages/MergeTree/MergeTreeIndexMinMax.cpp b/src/Storages/MergeTree/MergeTreeIndexMinMax.cpp index 35c52d6cd5e..2154c18f1a7 100644 --- a/src/Storages/MergeTree/MergeTreeIndexMinMax.cpp +++ b/src/Storages/MergeTree/MergeTreeIndexMinMax.cpp @@ -211,21 +211,6 @@ MergeTreeIndexConditionPtr MergeTreeIndexMinMax::createIndexCondition( return std::make_shared(index, query, context); } -bool MergeTreeIndexMinMax::mayBenefitFromIndexForIn(const ASTPtr & node) const -{ - const String column_name = node->getColumnName(); - - for (const auto & cname : index.column_names) - if (column_name == cname) - return true; - - if (const auto * func = typeid_cast(node.get())) - if (func->arguments->children.size() == 1) - return mayBenefitFromIndexForIn(func->arguments->children.front()); - - return false; -} - MergeTreeIndexFormat MergeTreeIndexMinMax::getDeserializedFormat(const IDataPartStorage & data_part_storage, const std::string & relative_path_prefix) const { if (data_part_storage.exists(relative_path_prefix + ".idx2")) diff --git a/src/Storages/MergeTree/MergeTreeIndexMinMax.h b/src/Storages/MergeTree/MergeTreeIndexMinMax.h index 4517a195362..a1a216fdf72 100644 --- a/src/Storages/MergeTree/MergeTreeIndexMinMax.h +++ b/src/Storages/MergeTree/MergeTreeIndexMinMax.h @@ -81,8 +81,6 @@ public: MergeTreeIndexConditionPtr createIndexCondition( const SelectQueryInfo & query, ContextPtr context) const override; - bool mayBenefitFromIndexForIn(const ASTPtr & node) const override; - const char* getSerializedFileExtension() const override { return ".idx2"; } MergeTreeIndexFormat getDeserializedFormat(const IDataPartStorage & data_part_storage, const std::string & path_prefix) const override; /// NOLINT }; diff --git a/src/Storages/MergeTree/MergeTreeIndexSet.cpp b/src/Storages/MergeTree/MergeTreeIndexSet.cpp index ec02d9418a7..612c5d868cb 100644 --- a/src/Storages/MergeTree/MergeTreeIndexSet.cpp +++ b/src/Storages/MergeTree/MergeTreeIndexSet.cpp @@ -709,11 +709,6 @@ MergeTreeIndexConditionPtr MergeTreeIndexSet::createIndexCondition( return std::make_shared(index.name, index.sample_block, max_rows, query, context); } -bool MergeTreeIndexSet::mayBenefitFromIndexForIn(const ASTPtr &) const -{ - return false; -} - MergeTreeIndexPtr setIndexCreator(const IndexDescription & index) { size_t max_rows = index.arguments[0].get(); diff --git a/src/Storages/MergeTree/MergeTreeIndexSet.h b/src/Storages/MergeTree/MergeTreeIndexSet.h index 022988c2453..a53476ca751 100644 --- a/src/Storages/MergeTree/MergeTreeIndexSet.h +++ b/src/Storages/MergeTree/MergeTreeIndexSet.h @@ -151,8 +151,6 @@ public: MergeTreeIndexConditionPtr createIndexCondition( const SelectQueryInfo & query, ContextPtr context) const override; - bool mayBenefitFromIndexForIn(const ASTPtr & node) const override; - size_t max_rows = 0; }; diff --git a/src/Storages/MergeTree/MergeTreeIndexUSearch.h b/src/Storages/MergeTree/MergeTreeIndexUSearch.h index bf58928a577..a7675620a2e 100644 --- a/src/Storages/MergeTree/MergeTreeIndexUSearch.h +++ b/src/Storages/MergeTree/MergeTreeIndexUSearch.h @@ -102,8 +102,6 @@ public: MergeTreeIndexAggregatorPtr createIndexAggregator(const MergeTreeWriterSettings & settings) const override; MergeTreeIndexConditionPtr createIndexCondition(const SelectQueryInfo & query, ContextPtr context) const override; - bool mayBenefitFromIndexForIn(const ASTPtr & /*node*/) const override { return false; } - private: const String distance_function; const unum::usearch::scalar_kind_t scalar_kind; diff --git a/src/Storages/MergeTree/MergeTreeIndices.h b/src/Storages/MergeTree/MergeTreeIndices.h index 77062f09be9..da1e914b90e 100644 --- a/src/Storages/MergeTree/MergeTreeIndices.h +++ b/src/Storages/MergeTree/MergeTreeIndices.h @@ -160,9 +160,6 @@ struct IMergeTreeIndex return {0 /*unknown*/, ""}; } - /// Checks whether the column is in data skipping index. - virtual bool mayBenefitFromIndexForIn(const ASTPtr & node) const = 0; - virtual MergeTreeIndexGranulePtr createIndexGranule() const = 0; virtual MergeTreeIndexAggregatorPtr createIndexAggregator(const MergeTreeWriterSettings & settings) const = 0;