Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cbadb34
add fp16 tests
meiravgri Aug 8, 2025
0f7b9d2
more tests
meiravgri Aug 9, 2025
beab7ee
add printing utility to VecSimQueryReply and VecSimQueryResult
meiravgri Aug 10, 2025
c93b35e
more tests
meiravgri Aug 10, 2025
0dfeefb
more tests
meiravgri Aug 12, 2025
289408d
imp getStoredVectorDataByLabel for multi and no-compressed
meiravgri Aug 12, 2025
371d5da
Merge remote-tracking branch 'origin/main' into meiravg_svs_fp16_tests
meiravgri Aug 12, 2025
4daae6a
fix quant_modes
meiravgri Aug 12, 2025
04ebb3e
multi index tests
meiravgri Aug 13, 2025
e5ba428
tiered tests
meiravgri Aug 13, 2025
9c338b3
fix test to fail
meiravgri Aug 14, 2025
b32675c
temproraly push test_override_all to float32 tests
meiravgri Aug 14, 2025
9253161
update to crash
meiravgri Aug 14, 2025
4e92106
revert svs tests chnages
meiravgri Aug 20, 2025
cb7210b
Merge branch 'main' into meiravg_svs_fp16_tests
meiravgri Aug 20, 2025
9414766
Merge branch 'main' into meiravg_svs_fp16_tests
meiravgri Aug 20, 2025
9b186b7
test
meiravgri Aug 20, 2025
3a82990
add range test
meiravgri Aug 20, 2025
70ed30e
skip test_get_distance for scalaar quant
meiravgri Aug 20, 2025
c97bfb3
align svs_get_distance name test with test_svs.cpp
meiravgri Aug 20, 2025
96a24e9
clean ups
meiravgri Aug 20, 2025
9b0aa4c
add coverage to print VecSimQueryResult and VecSimQueryReply
meiravgri Aug 20, 2025
2987fe7
guard validateSVSIndexAttributesInfo with #if HAVE_SVS for the include
meiravgri Aug 20, 2025
1a31d3b
fix
meiravgri Aug 20, 2025
bba597a
Merge branch 'main' into meiravg_svs_fp16_tests
meiravgri Oct 15, 2025
7e570b1
align names with main branhc
meiravgri Oct 15, 2025
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
40 changes: 38 additions & 2 deletions src/VecSim/algorithms/svs/svs.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,44 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
#ifdef BUILD_TESTS
void fitMemory() override {}
std::vector<std::vector<char>> getStoredVectorDataByLabel(labelType label) const override {
assert(false && "Not implemented");
return {};

// For compressed/quantized indices, this function is not meaningful
// since the stored data is in compressed format and not directly accessible
if constexpr (QuantBits > 0 || ResidualBits > 0) {
throw std::runtime_error(
"getStoredVectorDataByLabel is not supported for compressed/quantized indices");
} else {

std::vector<std::vector<char>> vectors_output;

if constexpr (isMulti) {
// Multi-index case: get all vectors for this label
auto it = impl_->get_label_to_external_lookup().find(label);
if (it != impl_->get_label_to_external_lookup().end()) {
const auto &external_ids = it->second;
for (auto external_id : external_ids) {
auto indexed_span = impl_->get_parent_index().get_datum(external_id);

// For uncompressed data, indexed_span should be a simple span
const char *data_ptr = reinterpret_cast<const char *>(indexed_span.data());
std::vector<char> vec_data(this->getDataSize());
std::memcpy(vec_data.data(), data_ptr, this->getDataSize());
vectors_output.push_back(std::move(vec_data));
}
}
} else {
// Single-index case
auto indexed_span = impl_->get_datum(label);

// For uncompressed data, indexed_span should be a simple span
const char *data_ptr = reinterpret_cast<const char *>(indexed_span.data());
std::vector<char> vec_data(this->getDataSize());
std::memcpy(vec_data.data(), data_ptr, this->getDataSize());
vectors_output.push_back(std::move(vec_data));
}

return vectors_output;
}
}
void getDataByLabel(
labelType label,
Expand Down
17 changes: 17 additions & 0 deletions src/VecSim/query_result_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,20 @@ struct VecSimQueryReply {
VecSimQueryReply_Code code = VecSim_QueryReply_OK)
: results(allocator), code(code) {}
};

#ifdef BUILD_TESTS
#include <iostream>

// Print operators
inline std::ostream &operator<<(std::ostream &os, const VecSimQueryResult &result) {
os << "id: " << result.id << ", score: " << result.score;
return os;
}

inline std::ostream &operator<<(std::ostream &os, const VecSimQueryReply &reply) {
for (const auto &result : reply.results) {
os << result << std::endl;
}
return os;
}
#endif
2 changes: 1 addition & 1 deletion tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ add_executable(test_fp16 ../utils/mock_thread_pool.cpp test_fp16.cpp unit_test_u
add_executable(test_int8 ../utils/mock_thread_pool.cpp test_int8.cpp unit_test_utils.cpp)
add_executable(test_uint8 ../utils/mock_thread_pool.cpp test_uint8.cpp unit_test_utils.cpp)
add_executable(test_index_test_utils ../utils/mock_thread_pool.cpp test_index_test_utils.cpp unit_test_utils.cpp)
add_executable(test_svs ../utils/mock_thread_pool.cpp test_svs.cpp test_svs_tiered.cpp test_svs_multi.cpp unit_test_utils.cpp)
add_executable(test_svs ../utils/mock_thread_pool.cpp test_svs.cpp test_svs_tiered.cpp test_svs_multi.cpp test_svs_fp16.cpp unit_test_utils.cpp)

target_link_libraries(test_hnsw PUBLIC gtest_main VectorSimilarity)
target_link_libraries(test_hnsw_parallel PUBLIC gtest_main VectorSimilarity)
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/test_index_test_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,20 @@ void IndexTestUtilsTest::get_stored_vector_data_single_test() {
EXPECT_NO_FATAL_FAILURE(this->ValidateVectors(stored_data, i));
}
}

TEST(QueryResultPrintTest, PrintOperators) {
// Test VecSimQueryResult print operator
VecSimQueryResult result = {.id = 42, .score = 3.14};
std::ostringstream oss1;
oss1 << result;
EXPECT_EQ(oss1.str(), "id: 42, score: 3.14");

// Test VecSimQueryReply print operator
VecSimQueryReply reply(VecSimAllocator::newVecsimAllocator());
reply.results.push_back({.id = 1, .score = 1.5});
reply.results.push_back({.id = 2, .score = 2.5});

std::ostringstream oss2;
oss2 << reply;
EXPECT_EQ(oss2.str(), "id: 1, score: 1.5\nid: 2, score: 2.5\n");
}
Loading
Loading