diff --git a/CMakeLists.txt b/CMakeLists.txt index 6edbf7e..9c87093 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,11 +8,12 @@ set(LOADABLE_EXTENSION_NAME ${TARGET_NAME}_loadable_extension) project(${TARGET_NAME}) -option(USE_SIMSIMD "Use SIMSIMD library to sacrifice portability for vectorized search" OFF) +option(USE_SIMSIMD + "Use SIMSIMD library to sacrifice portability for vectorized search" OFF) if(USE_SIMSIMD) - add_definitions(-DDUCKDB_USEARCH_USE_SIMSIMD=1) + add_definitions(-DDUCKDB_USEARCH_USE_SIMSIMD=1) else() - add_definitions(-DDUCKDB_USEARCH_USE_SIMSIMD=0) + add_definitions(-DDUCKDB_USEARCH_USE_SIMSIMD=0) endif() include_directories(src/include) diff --git a/src/hnsw/hnsw_index_macros.cpp b/src/hnsw/hnsw_index_macros.cpp index 38243dd..774b409 100644 --- a/src/hnsw/hnsw_index_macros.cpp +++ b/src/hnsw/hnsw_index_macros.cpp @@ -78,7 +78,7 @@ FROM // Register //------------------------------------------------------------------------- static void RegisterTableMacro(DatabaseInstance &db, const string &name, const string &query, - const vector ¶ms, const child_list_t &named_params) { + const vector ¶ms, const child_list_t &named_params) { Parser parser; parser.ParseQuery(query); @@ -106,14 +106,11 @@ static void RegisterTableMacro(DatabaseInstance &db, const string &name, const s void HNSWModule::RegisterMacros(DatabaseInstance &db) { - RegisterTableMacro(db, "vss_join", VSS_JOIN_MACRO, - {"left_table", "right_table", "left_col", "right_col", "k"}, - {{"metric", Value("l2sq")}}); - - RegisterTableMacro(db, "vss_match", VSS_MATCH_MACRO, - {"right_table", "left_col", "right_col", "k"}, - {{"metric", Value("l2sq")}}); + RegisterTableMacro(db, "vss_join", VSS_JOIN_MACRO, {"left_table", "right_table", "left_col", "right_col", "k"}, + {{"metric", Value("l2sq")}}); + RegisterTableMacro(db, "vss_match", VSS_MATCH_MACRO, {"right_table", "left_col", "right_col", "k"}, + {{"metric", Value("l2sq")}}); } } // namespace duckdb \ No newline at end of file diff --git a/src/hnsw/hnsw_index_physical_create.cpp b/src/hnsw/hnsw_index_physical_create.cpp index fbcb045..07eb2da 100644 --- a/src/hnsw/hnsw_index_physical_create.cpp +++ b/src/hnsw/hnsw_index_physical_create.cpp @@ -131,7 +131,8 @@ class HNSWIndexConstructTask final : public ExecutorTask { public: HNSWIndexConstructTask(shared_ptr event_p, ClientContext &context, CreateHNSWIndexGlobalState &gstate_p, size_t thread_id_p, const PhysicalCreateHNSWIndex &op_p) - : ExecutorTask(context, std::move(event_p), op_p), gstate(gstate_p), thread_id(thread_id_p), local_scan_state() { + : ExecutorTask(context, std::move(event_p), op_p), gstate(gstate_p), thread_id(thread_id_p), + local_scan_state() { // Initialize the scan chunk gstate.collection->InitializeScanChunk(scan_chunk); } @@ -209,9 +210,11 @@ class HNSWIndexConstructTask final : public ExecutorTask { class HNSWIndexConstructionEvent final : public BasePipelineEvent { public: - HNSWIndexConstructionEvent(const PhysicalCreateHNSWIndex &op_p, CreateHNSWIndexGlobalState &gstate_p, Pipeline &pipeline_p, CreateIndexInfo &info_p, - const vector &storage_ids_p, DuckTableEntry &table_p) - : BasePipelineEvent(pipeline_p), op(op_p), gstate(gstate_p), info(info_p), storage_ids(storage_ids_p), table(table_p) { + HNSWIndexConstructionEvent(const PhysicalCreateHNSWIndex &op_p, CreateHNSWIndexGlobalState &gstate_p, + Pipeline &pipeline_p, CreateIndexInfo &info_p, const vector &storage_ids_p, + DuckTableEntry &table_p) + : BasePipelineEvent(pipeline_p), op(op_p), gstate(gstate_p), info(info_p), storage_ids(storage_ids_p), + table(table_p) { } const PhysicalCreateHNSWIndex &op; diff --git a/test/sql/hnsw/hnsw_join_macro.test b/test/sql/hnsw/hnsw_join_macro.test index 6b8d095..b2f9863 100644 --- a/test/sql/hnsw/hnsw_join_macro.test +++ b/test/sql/hnsw/hnsw_join_macro.test @@ -12,7 +12,12 @@ CREATE TABLE s(s_vec FLOAT[3]); statement ok INSERT INTO s VALUES ([5,5,5]), ([1,1,1]); -query III +query I +SELECT bool_and(score <= 1.0) FROM vss_join(s, t1, s_vec, vec, 3) as res; +---- +true + +query I SELECT len(matches) = 3 FROM s, vss_match(t1, s_vec, vec, 3) as res; ---- true