Skip to content

Commit 0d83629

Browse files
committed
Clean-up code
1 parent bd0cd24 commit 0d83629

File tree

3 files changed

+38
-49
lines changed

3 files changed

+38
-49
lines changed

src/VecSim/algorithms/svs/svs_tiered.h

-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
/* TODO: change the copyright here */
2-
3-
/*
4-
*Copyright Redis Ltd. 2021 - present
5-
*Licensed under your choice of the Redis Source Available License 2.0 (RSALv2) or
6-
*the Server Side Public License v1 (SSPLv1).
7-
*/
8-
9-
/* TODO clean the includes */
101
#pragma once
112
#include "VecSim/algorithms/brute_force/brute_force_single.h"
123
#include "VecSim/vec_sim_tiered_index.h"
@@ -490,7 +481,6 @@ class TieredSVSIndex : public VecSimTieredIndex<DataType, float> {
490481
{ // lock both indicies for writing - these changes to be synchronized
491482
std::scoped_lock lock(this->flatIndexGuard, this->mainIndexGuard);
492483
auto svs_index = GetSVSIndex();
493-
// TODO(rfsaliev) remove below assuming that vectors had to be deleted directly
494484
auto deleted_num =
495485
svs_index->deleteVectors(labels_to_delete.data(), labels_to_delete.size());
496486
assert(deleted_num == 0);

src/VecSim/vec_sim_tiered_index.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ VecSimIndexDebugInfo VecSimTieredIndex<DataType, DistType>::debugInfo() const {
287287
case VecSimAlgo_HNSWLIB:
288288
info.tieredInfo.backendInfo.hnswInfo = backendInfo.hnswInfo;
289289
break;
290-
case VecSimAlgo_SVS: // TODO: Add SVS info.
290+
case VecSimAlgo_SVS:
291291
break;
292292
case VecSimAlgo_BF:
293293
case VecSimAlgo_TIERED:

tests/unit/test_svs_tiered.cpp

+37-38
Original file line numberDiff line numberDiff line change
@@ -489,44 +489,43 @@ TYPED_TEST(SVSTieredIndexTest, KNNSearch) {
489489
// Memory usage should not change.
490490
ASSERT_EQ(allocator->getAllocationSize(), cur_memory_usage);
491491

492-
// TODO: add timeouts support to SVS index and test it here.
493-
// // // // // // // // // // // // //
494-
// // Check behavior upon timeout. //
495-
// // // // // // // // // // // // //
496-
497-
// VecSimQueryReply *res;
498-
// // Add a vector to the SVS index so there will be a reason to query it.
499-
// GenerateAndAddVector<TEST_DATA_T>(svs_index, dim, n, n);
500-
501-
// // Set timeout callback to always return 1 (will fail while querying the flat buffer).
502-
// VecSim_SetTimeoutCallbackFunction([](void *ctx) { return 1; }); // Always times out
503-
504-
// res = VecSimIndex_TopKQuery(tiered_index, query_0, k, nullptr, BY_SCORE);
505-
// ASSERT_TRUE(res->results.empty());
506-
// ASSERT_EQ(VecSimQueryReply_GetCode(res), VecSim_QueryReply_TimedOut);
507-
// VecSimQueryReply_Free(res);
508-
509-
// // Set timeout callback to return 1 after n checks (will fail while querying the SVS index).
510-
// // Brute-force index checks for timeout after each vector.
511-
// size_t checks_in_flat = flat_index->indexSize();
512-
// VecSimQueryParams qparams = {.timeoutCtx = &checks_in_flat};
513-
// VecSim_SetTimeoutCallbackFunction([](void *ctx) {
514-
// auto count = static_cast<size_t *>(ctx);
515-
// if (*count == 0) {
516-
// return 1;
517-
// }
518-
// (*count)--;
519-
// return 0;
520-
// });
521-
// res = VecSimIndex_TopKQuery(tiered_index, query_0, k, &qparams, BY_SCORE);
522-
// ASSERT_TRUE(res->results.empty());
523-
// ASSERT_EQ(VecSimQueryReply_GetCode(res), VecSim_QueryReply_TimedOut);
524-
// VecSimQueryReply_Free(res);
525-
// // Make sure we didn't get the timeout in the flat index.
526-
// checks_in_flat = flat_index->indexSize(); // Reset the counter.
527-
// res = VecSimIndex_TopKQuery(flat_index, query_0, k, &qparams, BY_SCORE);
528-
// ASSERT_EQ(VecSimQueryReply_GetCode(res), VecSim_QueryReply_OK);
529-
// VecSimQueryReply_Free(res);
492+
// // // // // // // // // // // //
493+
// Check behavior upon timeout. //
494+
// // // // // // // // // // // //
495+
496+
VecSimQueryReply *res;
497+
// Add a vector to the SVS index so there will be a reason to query it.
498+
GenerateAndAddVector<TEST_DATA_T>(svs_index, dim, n, n);
499+
500+
// Set timeout callback to always return 1 (will fail while querying the flat buffer).
501+
VecSim_SetTimeoutCallbackFunction([](void *ctx) { return 1; }); // Always times out
502+
503+
res = VecSimIndex_TopKQuery(tiered_index, query_0, k, nullptr, BY_SCORE);
504+
ASSERT_TRUE(res->results.empty());
505+
ASSERT_EQ(VecSimQueryReply_GetCode(res), VecSim_QueryReply_TimedOut);
506+
VecSimQueryReply_Free(res);
507+
508+
// Set timeout callback to return 1 after n checks (will fail while querying the SVS index).
509+
// Brute-force index checks for timeout after each vector.
510+
size_t checks_in_flat = flat_index->indexSize();
511+
VecSimQueryParams qparams = {.timeoutCtx = &checks_in_flat};
512+
VecSim_SetTimeoutCallbackFunction([](void *ctx) {
513+
auto count = static_cast<size_t *>(ctx);
514+
if (*count == 0) {
515+
return 1;
516+
}
517+
(*count)--;
518+
return 0;
519+
});
520+
res = VecSimIndex_TopKQuery(tiered_index, query_0, k, &qparams, BY_SCORE);
521+
ASSERT_TRUE(res->results.empty());
522+
ASSERT_EQ(VecSimQueryReply_GetCode(res), VecSim_QueryReply_TimedOut);
523+
VecSimQueryReply_Free(res);
524+
// Make sure we didn't get the timeout in the flat index.
525+
checks_in_flat = flat_index->indexSize(); // Reset the counter.
526+
res = VecSimIndex_TopKQuery(flat_index, query_0, k, &qparams, BY_SCORE);
527+
ASSERT_EQ(VecSimQueryReply_GetCode(res), VecSim_QueryReply_OK);
528+
VecSimQueryReply_Free(res);
530529

531530
// Clean up.
532531
VecSim_SetTimeoutCallbackFunction([](void *ctx) { return 0; });

0 commit comments

Comments
 (0)