From 42644bfbf579bc9a2c79bd92df371340f3e02f5f Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Thu, 17 Aug 2023 09:44:10 +0000 Subject: [PATCH] Rename file to MergeTreeIndexUSearch.h/cpp --- ...ndexHnsw.cpp => MergeTreeIndexUSearch.cpp} | 41 ++++++++++++------- ...reeIndexHnsw.h => MergeTreeIndexUSearch.h} | 7 ++-- 2 files changed, 30 insertions(+), 18 deletions(-) rename src/Storages/MergeTree/{MergeTreeIndexHnsw.cpp => MergeTreeIndexUSearch.cpp} (93%) rename src/Storages/MergeTree/{MergeTreeIndexHnsw.h => MergeTreeIndexUSearch.h} (90%) diff --git a/src/Storages/MergeTree/MergeTreeIndexHnsw.cpp b/src/Storages/MergeTree/MergeTreeIndexUSearch.cpp similarity index 93% rename from src/Storages/MergeTree/MergeTreeIndexHnsw.cpp rename to src/Storages/MergeTree/MergeTreeIndexUSearch.cpp index b49a65c1895..eddbc61b11b 100644 --- a/src/Storages/MergeTree/MergeTreeIndexHnsw.cpp +++ b/src/Storages/MergeTree/MergeTreeIndexUSearch.cpp @@ -1,6 +1,6 @@ #ifdef ENABLE_USEARCH -#include +#include #include #include @@ -25,7 +25,6 @@ namespace ErrorCodes extern const int LOGICAL_ERROR; } - template USearchIndexWithSerialization::USearchIndexWithSerialization(size_t dimensions) : Base(Base::make(unum::usearch::metric_punned_t(dimensions, Metric))) @@ -64,17 +63,24 @@ size_t USearchIndexWithSerialization::getDimensions() const return Base::dimensions(); } - template -MergeTreeIndexGranuleUSearch::MergeTreeIndexGranuleUSearch(const String & index_name_, const Block & index_sample_block_) - : index_name(index_name_), index_sample_block(index_sample_block_), index(nullptr) +MergeTreeIndexGranuleUSearch::MergeTreeIndexGranuleUSearch( + const String & index_name_, + const Block & index_sample_block_) + : index_name(index_name_) + , index_sample_block(index_sample_block_) + , index(nullptr) { } template MergeTreeIndexGranuleUSearch::MergeTreeIndexGranuleUSearch( - const String & index_name_, const Block & index_sample_block_, USearchIndexWithSerializationPtr index_) - : index_name(index_name_), index_sample_block(index_sample_block_), index(std::move(index_)) + const String & index_name_, + const Block & index_sample_block_, + USearchIndexWithSerializationPtr index_) + : index_name(index_name_) + , index_sample_block(index_sample_block_) + , index(std::move(index_)) { } @@ -97,8 +103,11 @@ void MergeTreeIndexGranuleUSearch::deserializeBinary(ReadBuffer & istr, } template -MergeTreeIndexAggregatorUSearch::MergeTreeIndexAggregatorUSearch(const String & index_name_, const Block & index_sample_block_) - : index_name(index_name_), index_sample_block(index_sample_block_) +MergeTreeIndexAggregatorUSearch::MergeTreeIndexAggregatorUSearch( + const String & index_name_, + const Block & index_sample_block_) + : index_name(index_name_) + , index_sample_block(index_sample_block_) { } @@ -191,10 +200,13 @@ void MergeTreeIndexAggregatorUSearch::update(const Block & block, size_t *pos += rows_read; } - MergeTreeIndexConditionUSearch::MergeTreeIndexConditionUSearch( - const IndexDescription & /*index_description*/, const SelectQueryInfo & query, const String & distance_function_, ContextPtr context) - : ann_condition(query, context), distance_function(distance_function_) + const IndexDescription & /*index_description*/, + const SelectQueryInfo & query, + const String & distance_function_, + ContextPtr context) + : ann_condition(query, context) + , distance_function(distance_function_) { } @@ -265,11 +277,11 @@ std::vector MergeTreeIndexConditionUSearch::getUsefulRangesImpl(MergeTre } MergeTreeIndexUSearch::MergeTreeIndexUSearch(const IndexDescription & index_, const String & distance_function_) - : IMergeTreeIndex(index_), distance_function(distance_function_) + : IMergeTreeIndex(index_) + , distance_function(distance_function_) { } - MergeTreeIndexGranulePtr MergeTreeIndexUSearch::createIndexGranule() const { if (distance_function == DISTANCE_FUNCTION_L2) @@ -356,6 +368,7 @@ void usearchIndexValidator(const IndexDescription & index, bool /* attach */) else throw_unsupported_underlying_column_exception(); } + } #endif diff --git a/src/Storages/MergeTree/MergeTreeIndexHnsw.h b/src/Storages/MergeTree/MergeTreeIndexUSearch.h similarity index 90% rename from src/Storages/MergeTree/MergeTreeIndexHnsw.h rename to src/Storages/MergeTree/MergeTreeIndexUSearch.h index 89f5e3bb8cb..2b8ddf633d4 100644 --- a/src/Storages/MergeTree/MergeTreeIndexHnsw.h +++ b/src/Storages/MergeTree/MergeTreeIndexUSearch.h @@ -28,8 +28,7 @@ template struct MergeTreeIndexGranuleUSearch final : public IMergeTreeIndexGranule { MergeTreeIndexGranuleUSearch(const String & index_name_, const Block & index_sample_block_); - MergeTreeIndexGranuleUSearch( - const String & index_name_, const Block & index_sample_block_, USearchIndexWithSerializationPtr index_); + MergeTreeIndexGranuleUSearch(const String & index_name_, const Block & index_sample_block_, USearchIndexWithSerializationPtr index_); ~MergeTreeIndexGranuleUSearch() override = default; @@ -62,8 +61,7 @@ struct MergeTreeIndexAggregatorUSearch final : IMergeTreeIndexAggregator class MergeTreeIndexConditionUSearch final : public IMergeTreeIndexConditionApproximateNearestNeighbor { public: - MergeTreeIndexConditionUSearch( - const IndexDescription & index_description, const SelectQueryInfo & query, const String & distance_function, ContextPtr context); + MergeTreeIndexConditionUSearch(const IndexDescription & index_description, const SelectQueryInfo & query, const String & distance_function, ContextPtr context); ~MergeTreeIndexConditionUSearch() override = default; @@ -101,3 +99,4 @@ private: } #endif +