Skip to content

Commit

Permalink
cicd: Add usearch submodule (#162)
Browse files Browse the repository at this point in the history
* cmake: Fail fast when usearch is not found

Signed-off-by: Wish <[email protected]>

* Add submodule

Signed-off-by: Wish <[email protected]>

---------

Signed-off-by: Wish <[email protected]>
  • Loading branch information
breezewish authored and JaySon-Huang committed Aug 6, 2024
1 parent 1afddb3 commit f45d41a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions contrib/usearch
Submodule usearch added at b878f4
4 changes: 4 additions & 0 deletions contrib/usearch-cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 9 additions & 8 deletions dbms/src/Storages/DeltaMerge/Index/VectorIndexHNSW/Index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -189,12 +189,13 @@ std::vector<VectorIndex::Key> VectorIndexHNSW<Metric>::search(

RUNTIME_CHECK(index != nullptr);

auto predicate = [&valid_rows, &statistics](USearchIndexWithSerialization<Metric>::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<Metric>::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( //
Expand Down

0 comments on commit f45d41a

Please sign in to comment.