From f45d41a3866b17d7752b166e8d66507d747edbc3 Mon Sep 17 00:00:00 2001 From: Wenxuan Date: Mon, 18 Mar 2024 13:16:44 +0800 Subject: [PATCH] cicd: Add usearch submodule (#162) * cmake: Fail fast when usearch is not found Signed-off-by: Wish * Add submodule Signed-off-by: Wish --------- Signed-off-by: Wish --- contrib/usearch | 1 + contrib/usearch-cmake/CMakeLists.txt | 4 ++++ .../DeltaMerge/File/DMFileBlockInputStream.cpp | 3 ++- .../DeltaMerge/Index/VectorIndexHNSW/Index.cpp | 17 +++++++++-------- 4 files changed, 16 insertions(+), 9 deletions(-) create mode 160000 contrib/usearch diff --git a/contrib/usearch b/contrib/usearch new file mode 160000 index 00000000000..b878f4182c9 --- /dev/null +++ b/contrib/usearch @@ -0,0 +1 @@ +Subproject commit b878f4182c95d473acc31efc46876925dbaf88d1 diff --git a/contrib/usearch-cmake/CMakeLists.txt b/contrib/usearch-cmake/CMakeLists.txt index 48501dff779..672dfe4d428 100644 --- a/contrib/usearch-cmake/CMakeLists.txt +++ b/contrib/usearch-cmake/CMakeLists.txt @@ -3,6 +3,10 @@ set(USEARCH_SOURCE_DIR "${USEARCH_PROJECT_DIR}/include") add_library(_usearch INTERFACE) +if (NOT EXISTS "${USEARCH_SOURCE_DIR}/usearch/index.hpp") + message (FATAL_ERROR "submodule contrib/usearch not found") +endif() + target_include_directories(_usearch SYSTEM INTERFACE ${USEARCH_PROJECT_DIR}/simsimd/include ${USEARCH_PROJECT_DIR}/fp16/include diff --git a/dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp b/dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp index 0d216ffe9e2..d1bd1b9760c 100644 --- a/dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp +++ b/dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp @@ -205,7 +205,8 @@ SkippableBlockInputStreamPtr DMFileBlockInputStreamBuilder::build2( read_one_pack_every_time, tracing_id, enable_read_thread, - scan_context); + scan_context, + read_tag); DMFileWithVectorIndexBlockInputStreamPtr reader = DMFileWithVectorIndexBlockInputStream::create( ann_query_info, diff --git a/dbms/src/Storages/DeltaMerge/Index/VectorIndexHNSW/Index.cpp b/dbms/src/Storages/DeltaMerge/Index/VectorIndexHNSW/Index.cpp index b26da737bf4..a58539def4b 100644 --- a/dbms/src/Storages/DeltaMerge/Index/VectorIndexHNSW/Index.cpp +++ b/dbms/src/Storages/DeltaMerge/Index/VectorIndexHNSW/Index.cpp @@ -78,9 +78,9 @@ constexpr tipb::VectorDistanceMetric toTiDBQueryDistanceMetric(unum::usearch::me case unum::usearch::metric_kind_t::l2sq_k: return tipb::VectorDistanceMetric::L2; case unum::usearch::metric_kind_t::cos_k: - return tipb::VectorDistanceMetric::Cosine; + return tipb::VectorDistanceMetric::COSINE; default: - return tipb::VectorDistanceMetric::InvalidMetric; + return tipb::VectorDistanceMetric::INVALID_DISTANCE_METRIC; } } @@ -189,12 +189,13 @@ std::vector VectorIndexHNSW::search( RUNTIME_CHECK(index != nullptr); - auto predicate = [&valid_rows, &statistics](USearchIndexWithSerialization::member_cref_t const & member) { - statistics.visited_nodes++; - if (!valid_rows[member.key]) - statistics.discarded_nodes++; - return valid_rows[member.key]; - }; + auto predicate + = [&valid_rows, &statistics](typename USearchIndexWithSerialization::member_cref_t const & member) { + statistics.visited_nodes++; + if (!valid_rows[member.key]) + statistics.discarded_nodes++; + return valid_rows[member.key]; + }; // TODO: Support efSearch. auto result = index->search( //