Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
ebd71b0
Add OMEGALib as git submodule in thirdparty/omega
driPyf Jan 28, 2026
d0e6be3
Change omega submodule URL from SSH to HTTPS
driPyf Jan 28, 2026
7890bcd
Implement OMEGA index algorithm as wrapper around HNSW
driPyf Jan 28, 2026
ccbb36b
Merge branch 'alibaba:main' into main
driPyf Jan 29, 2026
4fbdbd4
feat: add OMEGA index support with Python bindings and tests
driPyf Jan 30, 2026
65ee973
chore: update OMEGA submodule to latest commit
driPyf Jan 30, 2026
4a19996
chore: update OMEGA submodule to latest commit
driPyf Mar 1, 2026
3d6cb13
feat: implement OMEGA adaptive search with training mode and per-quer…
driPyf Mar 1, 2026
87cc148
fix(omega): fix training memory leak and enable auto-training workflow
driPyf Mar 2, 2026
607b17c
perf(omega): parallelize training data collection and expose training…
driPyf Mar 3, 2026
9f38ea2
feat(omega): migrate to LightGBM C API and add conditional compilation
driPyf Mar 6, 2026
4f982d0
feat(omega): add OmegaQueryParam to Python API
driPyf Mar 8, 2026
7e0042b
perf(omega): optimize training memory by collecting data before flush
driPyf Mar 16, 2026
8640773
feat(omega): integrate the reference-aligned OMEGA training flow and …
driPyf Mar 17, 2026
f770de3
perf(omega): batch OMEGA distance evaluation, clean temporary trainin…
driPyf Mar 19, 2026
347bcf4
feat(omega): add retrain-only model refresh with cached held-out queries
driPyf Mar 21, 2026
bb8c5a2
chore(thirdparty): nest OMEGALib under thirdparty/omega
driPyf Mar 21, 2026
55875cd
chore(thirdparty): add omega wrapper cmake layer
driPyf Mar 21, 2026
5a195f0
feat(scripts): align benchmark presets and export profiling summaries
driPyf Mar 22, 2026
53e0b55
chore(scripts): update OMEGA training defaults for benchmark runs
driPyf Mar 22, 2026
420b4c4
fix(scripts): invoke VectorDBBench CLI instead of Streamlit entrypoint
driPyf Mar 22, 2026
27fda47
fix(scripts): avoid piping main benchmark output during profiling runs
driPyf Mar 22, 2026
543d16d
chore(scripts): rename online profiling fields and persist summary be…
driPyf Mar 22, 2026
9d750ff
fix(scripts): persist per-index profiling summaries and stabilize cap…
driPyf Mar 22, 2026
308d8ba
fix(scripts): enable zvec info logs during profiling passes
driPyf Mar 22, 2026
e548017
fix(omega): align search-core timing and reduce traversal overhead
driPyf Mar 22, 2026
5300d35
perf(omega): add compile-time control timing profiling and align benc…
driPyf Mar 22, 2026
4871eae
refactor(omega): move control timing profiling to runtime flags
driPyf Mar 22, 2026
5df2d5a
refactor(omega): align omega search path with hnsw core loop
driPyf Mar 22, 2026
4078546
feat(omega): add hooks-only perf switch and ab script
driPyf Mar 23, 2026
acf2a83
refactor(omega): split search profiling timings
driPyf Mar 23, 2026
c03a460
fix(omega): restore profiling timer callback build
driPyf Mar 23, 2026
66f6533
fix(omega): correct hook timing units
driPyf Mar 23, 2026
16e2fc4
Make omega model training deterministic
driPyf Mar 23, 2026
4f66406
Improve HNSW profiling and timing consistency
driPyf Mar 23, 2026
c5ce7cd
Add HNSW hooks microbenchmark tooling
driPyf Mar 23, 2026
0f53cf6
Add HNSW hooks perf analysis tooling
driPyf Mar 24, 2026
97cd0f6
Fix HNSW hooks microbench benchmark loading
driPyf Mar 24, 2026
bbd3259
Reduce omega hook bookkeeping overhead
driPyf Mar 24, 2026
ca7e2e3
Update omega traversal window tracking
driPyf Mar 25, 2026
6d1da95
Revert omega traversal window gating
driPyf Mar 25, 2026
255fd53
Fix HNSW query stats logging format
driPyf Mar 25, 2026
9027bb9
Restore benchmark concurrency sweep
driPyf Mar 25, 2026
6f3d2b4
Add configurable HNSW vs OMEGA benchmark runner
driPyf Mar 25, 2026
33cea2f
Add fine-grained omega control path profiling
driPyf Mar 25, 2026
6a2ca32
Add fine-grained timing fields to benchmark script
driPyf Mar 25, 2026
deed4ad
Update OMEGALib: lazy traversal window tracking
driPyf Mar 25, 2026
3eaadd2
Use fused ReportVisitCandidate return value to eliminate ShouldPredic…
driPyf Mar 26, 2026
af7dbac
Align omega hooks with fused prediction signal
driPyf Mar 26, 2026
22d2308
Throttle omega hooks by min interval
driPyf Mar 26, 2026
7ae1d76
Bound omega batching by next prediction cmp
driPyf Mar 26, 2026
7fc1894
Update OMEGALib weighted BH cache
driPyf Mar 26, 2026
5c453ac
Add latency percentiles to HNSW/OMEGA benchmark summary
driPyf Mar 26, 2026
08bde0c
Update OMEGALib conservative avg recall merge
driPyf Mar 26, 2026
2a4ed6a
Add OMEGA training and stop diagnostics
driPyf Mar 26, 2026
209cdae
Update OMEGALib after diagnostics fix
driPyf Mar 26, 2026
567ea41
Make OMEGA k_train configurable
driPyf Mar 26, 2026
97c9722
Drop extra omega runtime diagnostics
driPyf Mar 26, 2026
cf0a70a
Update benchmark HNSW vs OMEGA config
driPyf Mar 29, 2026
fecd57e
cleanup: clarify omega runtime ownership
driPyf Mar 29, 2026
16be71e
cleanup: document hnsw hook semantics
driPyf Mar 29, 2026
16b2605
cleanup: classify omega runtime flags
driPyf Mar 29, 2026
e6e5113
cleanup: extract omega training coordinator
driPyf Mar 29, 2026
f1caada
cleanup: share omega hook control path
driPyf Mar 29, 2026
cfe6756
cleanup: extract benchmark runner helpers
driPyf Mar 29, 2026
0578983
cleanup: consolidate benchmark entrypoints
driPyf Mar 29, 2026
8f73f01
cleanup: remove stale omega integration comments
driPyf Mar 29, 2026
52e657c
cleanup: classify internal perf tooling
driPyf Mar 29, 2026
d87adfc
cleanup: revert uploaded doc changes
driPyf Mar 29, 2026
b279fa2
cleanup: restore tool readme formatting
driPyf Mar 29, 2026
f2e1dc8
cleanup: align tool readme with main
driPyf Mar 29, 2026
4f67fb1
cleanup: drop stale omega tests and dead searcher paths
driPyf Mar 29, 2026
0013fb4
cleanup: trim unused omega accessors and state
driPyf Mar 29, 2026
dbba6dc
cleanup: drop obsolete omega benchmark helpers
driPyf Mar 29, 2026
1c53fd5
cleanup: refactor omega training around sessions
driPyf Mar 29, 2026
9d4db08
cleanup: trim stale omega training paths
driPyf Mar 29, 2026
7a9d8e2
cleanup: add benchmark concurrent warmup defaults
driPyf Mar 29, 2026
c2a82c9
cleanup: remove unused omega prediction microbench
driPyf Mar 29, 2026
1d3d89e
cleanup: switch benchmark flow to core tools
driPyf Mar 29, 2026
b51bde8
cleanup: add dataset auto-download for benchmark scripts
driPyf Mar 29, 2026
22bbd40
cleanup: surface benchmark script failure output
driPyf Mar 29, 2026
6dd8289
cleanup: drop benchmark refiner and warmup config
driPyf Mar 29, 2026
e898606
cleanup: sync omega library cleanup
driPyf Mar 30, 2026
9bae453
cleanup: sync omega feature extractor removal
driPyf Mar 30, 2026
546a838
cleanup: sync omega trainer cleanup
driPyf Mar 30, 2026
43ca6ec
update benchmark config to m64 recall092
driPyf Mar 30, 2026
61dc836
update cohere10m benchmark params
driPyf Mar 31, 2026
f086f4f
Remove OMEGA profiling path
driPyf Apr 1, 2026
c7e4449
Merge branch 'main' into feat/omega-integration
driPyf Apr 1, 2026
5a30ab4
Update OMEGA tests and integration code
driPyf Apr 1, 2026
d98b153
Simplify OMEGA build integration
driPyf Apr 1, 2026
758895f
Fix OMEGA context filter naming
driPyf Apr 1, 2026
a0c59c1
Add OMEGA workflow Python tests
driPyf Apr 1, 2026
ec74517
Stabilize OMEGA fallback test
driPyf Apr 1, 2026
7d1c191
Update OMEGALib submodule
driPyf Apr 1, 2026
0968728
Update OMEGALib submodule
driPyf Apr 1, 2026
1976fc9
Fix benchmark script lint issues
driPyf Apr 2, 2026
2c30539
Format benchmark Python code
driPyf Apr 2, 2026
6a53e63
Format C++ code with clang-format
driPyf Apr 2, 2026
07980c7
Update OMEGALib submodule
driPyf Apr 2, 2026
90ffba5
Fix recursive submodule init in CI
driPyf Apr 2, 2026
0b7309c
Update OMEGALib for Windows UTF-8 fix
driPyf Apr 2, 2026
0c6f8c4
Update OMEGALib for Android network build fix
driPyf Apr 2, 2026
43b3afd
Fix omega unit test link dependencies
driPyf Apr 2, 2026
be84830
Update OMEGALib for LightGBM stub linkage
driPyf Apr 2, 2026
6607743
Fix HNSW core utility linkage on macOS
driPyf Apr 2, 2026
0c728dd
Tighten core target link dependencies
driPyf Apr 2, 2026
77f56b8
Update OMEGALib for stub compile flags
driPyf Apr 2, 2026
527dc70
Update OMEGALib for USE_SOCKET stub fix
driPyf Apr 2, 2026
013795d
Update OMEGALib for Linkers stub emission
driPyf Apr 2, 2026
9258982
Revert OMEGALib LightGBM stub workaround
driPyf Apr 2, 2026
fceebba
Fix MSVC UTF-8 and core interface link deps
driPyf Apr 2, 2026
5f36f3c
Fix omega build and optimize regressions
driPyf Apr 2, 2026
7dfd196
Format omega integration fixes
driPyf Apr 2, 2026
63bc93b
Fix example linking and rename steady timer
driPyf Apr 2, 2026
c045298
Fix macOS examples and C++17 training init
driPyf Apr 2, 2026
02246e3
Keep omega binding registration linked
driPyf Apr 3, 2026
346d8b6
Gate omega build paths and tests by platform/config
driPyf Apr 3, 2026
aec406c
Fix Android examples OpenMP and pytest 9 fixture skips
driPyf Apr 3, 2026
c173e8f
chore: sync pytest omega test formatting
driPyf Apr 3, 2026
2464112
fix: link omega examples on windows
driPyf Apr 3, 2026
04dedbd
fix: stabilize omega example linking
driPyf Apr 3, 2026
5fafa0e
fix: simplify example library paths
driPyf Apr 3, 2026
c61bf58
ci: add windows examples workflow
driPyf Apr 3, 2026
1bcae21
ci: simplify windows examples triggers
driPyf Apr 3, 2026
0c0d767
ci: remove windows examples workflow
driPyf Apr 3, 2026
bd4697c
Add OMEGA integration test and examples
driPyf Apr 5, 2026
88a1aa7
Fix lint formatting for OMEGA changes
driPyf Apr 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/04-android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive

- name: Cache dependencies
uses: actions/cache@v5
Expand Down Expand Up @@ -60,7 +62,7 @@ jobs:
- name: Use host env to compile protoc
shell: bash
run: |
git submodule update --init
git submodule update --init --recursive
if [ ! -d "build-host" ]; then
export CCACHE_BASEDIR="$GITHUB_WORKSPACE"
export CCACHE_NOHASHDIR=1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scripts/run_vdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ echo "workspace: $GITHUB_WORKSPACE"
DB_LABEL_PREFIX="Zvec16c64g-$COMMIT_ID"

# install zvec
git submodule update --init
git submodule update --init --recursive

# for debug
#cd ..
Expand Down Expand Up @@ -85,4 +85,4 @@ EOF
cat prom_metrics.txt
curl --data-binary @prom_metrics.txt "http://47.93.34.27:9091/metrics/job/benchmarks-${CASE_TYPE}/case_type/${CASE_TYPE}/quantize_type/${QUANTIZE_TYPE}" -v
done
done
done
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
path = thirdparty/magic_enum/magic_enum-0.9.7
url = https://github.com/Neargye/magic_enum.git
ignore = all
[submodule "thirdparty/omega/OMEGALib"]
path = thirdparty/omega/OMEGALib
url = https://github.com/driPyf/OMEGALib.git
[submodule "thirdparty/RaBitQ-Library/RaBitQ-Library-0.1"]
path = thirdparty/RaBitQ-Library/RaBitQ-Library-0.1
url = https://github.com/VectorDB-NTU/RaBitQ-Library.git
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ message(STATUS "BUILD_C_BINDINGS:${BUILD_C_BINDINGS}")
option(BUILD_TOOLS "Build tools" ON)
message(STATUS "BUILD_TOOLS:${BUILD_TOOLS}")

if(ANDROID)
option(ZVEC_ENABLE_OMEGA "Build OMEGA support" OFF)
else()
option(ZVEC_ENABLE_OMEGA "Build OMEGA support" ON)
endif()
message(STATUS "ZVEC_ENABLE_OMEGA:${ZVEC_ENABLE_OMEGA}")
add_compile_definitions(ZVEC_ENABLE_OMEGA=$<BOOL:${ZVEC_ENABLE_OMEGA}>)

option(RABITQ_ENABLE_AVX512 "Compile RaBitQ with AVX-512 support" OFF)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64" AND NOT ANDROID)
Expand Down
6 changes: 3 additions & 3 deletions cmake/bazel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
"$<$<CXX_COMPILER_ID:Clang>:-Wall;-Wextra;-Wshadow>"
"$<$<CXX_COMPILER_ID:AppleClang>:-Wall;-Wextra;-Wshadow>"
"$<$<CXX_COMPILER_ID:GNU>:-Wall;-Wextra;-Wshadow-local;-Wno-misleading-indentation>"
"$<$<CXX_COMPILER_ID:MSVC>:/W4>"
"$<$<CXX_COMPILER_ID:MSVC>:/W4;/utf-8>"
${BAZEL_CC_ASAN_COMPILE_FLAGS}
${BAZEL_CC_COVERAGE_COMPILE_FLAGS}
)
Expand All @@ -463,7 +463,7 @@ else()
"$<$<CXX_COMPILER_ID:Clang>:-Wall;-Wextra;-Wshadow>"
"$<$<CXX_COMPILER_ID:AppleClang>:-Wall;-Wextra;-Wshadow>"
"$<$<CXX_COMPILER_ID:GNU>:-Wall;-Wextra;-Wshadow;-Wno-misleading-indentation>"
"$<$<CXX_COMPILER_ID:MSVC>:/W4>"
"$<$<CXX_COMPILER_ID:MSVC>:/W4;/utf-8>"
${BAZEL_CC_ASAN_COMPILE_FLAGS}
${BAZEL_CC_COVERAGE_COMPILE_FLAGS}
)
Expand All @@ -484,7 +484,7 @@ set(
"$<$<CXX_COMPILER_ID:Clang>:-Wall>"
"$<$<CXX_COMPILER_ID:AppleClang>:-Wall>"
"$<$<CXX_COMPILER_ID:GNU>:-Wall>"
"$<$<CXX_COMPILER_ID:MSVC>:/W3>"
"$<$<CXX_COMPILER_ID:MSVC>:/W3;/utf-8>"
${BAZEL_CC_ASAN_COMPILE_FLAGS}
${BAZEL_CC_COVERAGE_COMPILE_FLAGS}
)
Expand Down
73 changes: 73 additions & 0 deletions examples/c++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ set(ZVEC_INCLUDE_DIR ${CMAKE_BINARY_DIR}/../../../src/include)
set(ZVEC_LIB_DIR ${CMAKE_BINARY_DIR}/../../../${HOST_BUILD_DIR}/lib)
set(ZVEC_DEPENDENCY_LIB_DIR ${CMAKE_BINARY_DIR}/../../../${HOST_BUILD_DIR}/external/usr/local/lib)

if(ANDROID)
option(ZVEC_ENABLE_OMEGA "Link examples against OMEGA support from the host build" OFF)
else()
option(ZVEC_ENABLE_OMEGA "Link examples against OMEGA support from the host build" ON)
endif()

# Add include and library search paths
include_directories(${ZVEC_INCLUDE_DIR})
link_directories(${ZVEC_LIB_DIR} ${ZVEC_DEPENDENCY_LIB_DIR})
Expand All @@ -31,13 +37,48 @@ else()
set(PROTOBUF_LIB protobuf)
endif()

if(ZVEC_ENABLE_OMEGA)
set(_zvec_omega_search_paths
${ZVEC_DEPENDENCY_LIB_DIR}
${ZVEC_DEPENDENCY_LIB_DIR}/Debug
${ZVEC_DEPENDENCY_LIB_DIR}/Release
${ZVEC_DEPENDENCY_LIB_DIR}/RelWithDebInfo
${ZVEC_DEPENDENCY_LIB_DIR}/MinSizeRel
)
find_library(ZVEC_OMEGA_LIB
NAMES omega
PATHS ${_zvec_omega_search_paths}
NO_DEFAULT_PATH
)
find_library(ZVEC_LIGHTGBM_LIB
NAMES lib_lightgbm _lightgbm
PATHS ${_zvec_omega_search_paths}
NO_DEFAULT_PATH
)
if(NOT ZVEC_OMEGA_LIB OR NOT ZVEC_LIGHTGBM_LIB)
message(FATAL_ERROR
"ZVEC_ENABLE_OMEGA=ON but failed to locate OMEGA host libraries under "
"${ZVEC_DEPENDENCY_LIB_DIR}"
)
endif()
endif()

# --- Dependency groups ---
find_package(Threads REQUIRED)
find_package(OpenMP QUIET)

set(zvec_openmp_deps)
if(OpenMP_FOUND AND NOT ANDROID)
list(APPEND zvec_openmp_deps OpenMP::OpenMP_CXX)
endif()

set(zvec_core_deps
zvec_turbo
${zvec_openmp_deps}
)
if(ZVEC_ENABLE_OMEGA)
list(APPEND zvec_core_deps ${ZVEC_OMEGA_LIB} ${ZVEC_LIGHTGBM_LIB})
endif()

if (NOT WIN32)
set(zvec_ailego_deps
Expand All @@ -63,7 +104,11 @@ if (NOT WIN32)
${GFLAGS_LIB}
${PROTOBUF_LIB}
lz4
${zvec_openmp_deps}
)
if(ZVEC_ENABLE_OMEGA)
list(APPEND zvec_db_deps ${ZVEC_OMEGA_LIB} ${ZVEC_LIGHTGBM_LIB})
endif()
else ()
# Windows static libraries use different naming conventions
set(PROTOBUF_LIB libprotobuf)
Expand All @@ -90,7 +135,11 @@ else ()
lz4
rpcrt4
shlwapi
${zvec_openmp_deps}
)
if(ZVEC_ENABLE_OMEGA)
list(APPEND zvec_db_deps ${ZVEC_OMEGA_LIB} ${ZVEC_LIGHTGBM_LIB})
endif()
endif ()

# --- Create INTERFACE targets for Zvec components ---
Expand Down Expand Up @@ -127,6 +176,11 @@ elseif(APPLE)
zvec-ailego
${zvec_core_deps}
)
if(ZVEC_ENABLE_OMEGA)
target_link_libraries(zvec-core INTERFACE
-Wl,-force_load ${ZVEC_OMEGA_LIB}
)
endif()
elseif(ANDROID)
target_link_libraries(zvec-core INTERFACE
-Wl,--whole-archive
Expand Down Expand Up @@ -161,6 +215,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
)
elseif(APPLE)
target_link_libraries(zvec-db INTERFACE
-Wl,-force_load ${ZVEC_LIB_DIR}/libzvec_db.a
zvec_db
zvec-core
zvec-ailego
Expand Down Expand Up @@ -208,6 +263,13 @@ target_link_libraries(ailego-example PRIVATE
zvec-ailego
)

if(ZVEC_ENABLE_OMEGA)
add_executable(omega-example omega/main.cc)
target_link_libraries(omega-example PRIVATE
zvec-core
)
endif()

# Strip symbols to reduce executable size
if(CMAKE_BUILD_TYPE STREQUAL "Release" AND ANDROID)
add_custom_command(TARGET db-example POST_BUILD
Expand All @@ -219,6 +281,11 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release" AND ANDROID)
add_custom_command(TARGET ailego-example POST_BUILD
COMMAND ${CMAKE_STRIP} "$<TARGET_FILE:ailego-example>"
COMMENT "Stripping symbols from ailego-example")
if(ZVEC_ENABLE_OMEGA)
add_custom_command(TARGET omega-example POST_BUILD
COMMAND ${CMAKE_STRIP} "$<TARGET_FILE:omega-example>"
COMMENT "Stripping symbols from omega-example")
endif()
endif()

# Optimize for size
Expand All @@ -227,4 +294,10 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release" AND ANDROID)
PROPERTY COMPILE_FLAGS "-Os")
set_property(TARGET db-example core-example ailego-example
PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
if(ZVEC_ENABLE_OMEGA)
set_property(TARGET omega-example
PROPERTY COMPILE_FLAGS "-Os")
set_property(TARGET omega-example
PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
endif()
92 changes: 92 additions & 0 deletions examples/c++/omega/main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include <filesystem>
#include <iostream>
#include <vector>
#include <zvec/core/interface/index.h>
#include <zvec/core/interface/index_factory.h>
#include <zvec/core/interface/index_param_builders.h>

using namespace zvec::core_interface;

namespace {

constexpr uint32_t kDimension = 32;
const std::string kIndexPath = "omega_example.index";

BaseIndexParam::Pointer CreateOmegaParam() {
auto param = HNSWIndexParamBuilder()
.WithMetricType(MetricType::kInnerProduct)
.WithDataType(DataType::DT_FP32)
.WithDimension(kDimension)
.WithIsSparse(false)
.WithM(8)
.WithEFConstruction(64)
.Build();
param->index_type = IndexType::kOMEGA;
return param;
}

} // namespace

int main() {
std::filesystem::remove_all(kIndexPath);

auto index = IndexFactory::CreateAndInitIndex(*CreateOmegaParam());
if (!index) {
std::cerr << "failed to create omega index" << std::endl;
return 1;
}

if (index->Open(kIndexPath, StorageOptions{StorageOptions::StorageType::kMMAP,
true}) != 0) {
std::cerr << "failed to open omega index" << std::endl;
return 1;
}

for (uint32_t doc_id = 0; doc_id < 6; ++doc_id) {
std::vector<float> values(kDimension, static_cast<float>(doc_id) / 10.0f);
values[0] = 1.0f + static_cast<float>(doc_id);
VectorData vector_data;
vector_data.vector = DenseVector{values.data()};
if (index->Add(vector_data, doc_id) != 0) {
std::cerr << "failed to add document " << doc_id << std::endl;
return 1;
}
}

if (index->Train() != 0) {
std::cerr << "failed to train omega index" << std::endl;
return 1;
}

std::vector<float> query_values(kDimension, 0.0f);
query_values[0] = 1.0f;
VectorData query{DenseVector{query_values.data()}};

auto query_param = OmegaQueryParamBuilder()
.with_topk(3)
.with_fetch_vector(true)
.with_ef_search(32)
.with_target_recall(0.95f)
.build();

SearchResult result;
if (index->Search(query, query_param, &result) != 0) {
std::cerr << "failed to search omega index" << std::endl;
return 1;
}

std::cout << "omega results: " << result.doc_list_.size() << std::endl;
if (result.doc_list_.empty()) {
std::cerr << "omega example returned no results" << std::endl;
return 1;
}

std::cout << "top result key=" << result.doc_list_[0].key()
<< " score=" << result.doc_list_[0].score() << std::endl;
if (index->Close() != 0) {
std::cerr << "failed to close omega index" << std::endl;
return 1;
}

return 0;
}
Loading