diff --git a/src/VecSim/algorithms/hnsw/hnsw_tiered.h b/src/VecSim/algorithms/hnsw/hnsw_tiered.h index 4932516d7..f9d94dc52 100644 --- a/src/VecSim/algorithms/hnsw/hnsw_tiered.h +++ b/src/VecSim/algorithms/hnsw/hnsw_tiered.h @@ -1183,7 +1183,6 @@ VecSimDebugInfoIterator *TieredHNSWIndex::debugInfoIterator( template VecSimIndexBasicInfo TieredHNSWIndex::basicInfo() const { VecSimIndexBasicInfo info = this->backendIndex->getBasicInfo(); - info.blockSize = info.blockSize; info.isTiered = true; info.algo = VecSimAlgo_HNSWLIB; return info; diff --git a/src/VecSim/index_factories/factory_utils.h b/src/VecSim/index_factories/factory_utils.h index 79343b618..271d2b5cc 100644 --- a/src/VecSim/index_factories/factory_utils.h +++ b/src/VecSim/index_factories/factory_utils.h @@ -33,6 +33,7 @@ static AbstractIndexInitParams NewAbstractInitParams(const IndexParams *algo_par .metric = algo_params->metric, .blockSize = algo_params->blockSize, .multi = algo_params->multi, + .isDisk = false, .logCtx = logCtx, .inputBlobSize = inputBlobSize}; return abstractInitParams; diff --git a/src/VecSim/utils/vec_utils.cpp b/src/VecSim/utils/vec_utils.cpp index ed353ab89..edb3fc989 100644 --- a/src/VecSim/utils/vec_utils.cpp +++ b/src/VecSim/utils/vec_utils.cpp @@ -44,6 +44,7 @@ const char *VecSimCommonStrings::DIMENSION_STRING = "DIMENSION"; const char *VecSimCommonStrings::INDEX_SIZE_STRING = "INDEX_SIZE"; const char *VecSimCommonStrings::INDEX_LABEL_COUNT_STRING = "INDEX_LABEL_COUNT"; const char *VecSimCommonStrings::IS_MULTI_STRING = "IS_MULTI_VALUE"; +const char *VecSimCommonStrings::IS_DISK_STRING = "IS_DISK"; const char *VecSimCommonStrings::MEMORY_STRING = "MEMORY"; const char *VecSimCommonStrings::HNSW_EF_RUNTIME_STRING = "EF_RUNTIME"; diff --git a/src/VecSim/utils/vec_utils.h b/src/VecSim/utils/vec_utils.h index 9e3cd74df..53adb62bb 100644 --- a/src/VecSim/utils/vec_utils.h +++ b/src/VecSim/utils/vec_utils.h @@ -44,6 +44,7 @@ struct VecSimCommonStrings { static const char *INDEX_SIZE_STRING; static const char *INDEX_LABEL_COUNT_STRING; static const char *IS_MULTI_STRING; + static const char *IS_DISK_STRING; static const char *MEMORY_STRING; static const char *HNSW_EF_RUNTIME_STRING; diff --git a/src/VecSim/vec_sim_common.h b/src/VecSim/vec_sim_common.h index c73ae1591..8b30a5fc5 100644 --- a/src/VecSim/vec_sim_common.h +++ b/src/VecSim/vec_sim_common.h @@ -327,6 +327,7 @@ typedef struct { VecSimType type; // Datatype the index holds. bool isMulti; // Determines if the index should multi-index or not. bool isTiered; // Is the index is tiered or not. + bool isDisk; // Is the index stored on disk. size_t blockSize; // Brute force algorithm vector block (mini matrix) size size_t dim; // Vector size (dimension). } VecSimIndexBasicInfo; diff --git a/src/VecSim/vec_sim_index.h b/src/VecSim/vec_sim_index.h index 8d9543e37..5cd18d38d 100644 --- a/src/VecSim/vec_sim_index.h +++ b/src/VecSim/vec_sim_index.h @@ -47,6 +47,7 @@ struct AbstractIndexInitParams { VecSimMetric metric; size_t blockSize; bool multi; + bool isDisk; // Whether the index stores vectors on disk void *logCtx; size_t inputBlobSize; }; @@ -80,6 +81,7 @@ struct VecSimIndexAbstract : public VecSimIndexInterface { // resizing) mutable VecSearchMode lastMode; // The last search mode in RediSearch (used for debug/testing). bool isMulti; // Determines if the index should multi-index or not. + bool isDisk; // Whether the index stores vectors on disk. void *logCallbackCtx; // Context for the log callback. RawDataContainer *vectors; // The raw vectors data container. private: @@ -119,7 +121,7 @@ struct VecSimIndexAbstract : public VecSimIndexInterface { : VecSimIndexInterface(params.allocator), dim(params.dim), vecType(params.vecType), metric(params.metric), blockSize(params.blockSize ? params.blockSize : DEFAULT_BLOCK_SIZE), lastMode(EMPTY_MODE), - isMulti(params.multi), logCallbackCtx(params.logCtx), + isMulti(params.multi), isDisk(params.isDisk), logCallbackCtx(params.logCtx), indexCalculator(components.indexCalculator), preprocessors(components.preprocessors), inputBlobSize(params.inputBlobSize), storedDataSize(params.storedDataSize) { assert(VecSimType_sizeof(vecType)); @@ -243,6 +245,10 @@ struct VecSimIndexAbstract : public VecSimIndexInterface { VecSim_InfoField{.fieldName = VecSimCommonStrings::IS_MULTI_STRING, .fieldType = INFOFIELD_UINT64, .fieldValue = {FieldValue{.uintegerValue = info.basicInfo.isMulti}}}); + infoIterator->addInfoField( + VecSim_InfoField{.fieldName = VecSimCommonStrings::IS_DISK_STRING, + .fieldType = INFOFIELD_UINT64, + .fieldValue = {FieldValue{.uintegerValue = info.basicInfo.isDisk}}}); infoIterator->addInfoField( VecSim_InfoField{.fieldName = VecSimCommonStrings::INDEX_SIZE_STRING, .fieldType = INFOFIELD_UINT64, @@ -271,6 +277,7 @@ struct VecSimIndexAbstract : public VecSimIndexInterface { .metric = this->metric, .type = this->vecType, .isMulti = this->isMulti, + .isDisk = this->isDisk, .blockSize = this->blockSize, .dim = this->dim, }; diff --git a/src/VecSim/vec_sim_tiered_index.h b/src/VecSim/vec_sim_tiered_index.h index ae18b8571..0a36b1f86 100644 --- a/src/VecSim/vec_sim_tiered_index.h +++ b/src/VecSim/vec_sim_tiered_index.h @@ -360,6 +360,7 @@ VecSimIndexDebugInfo VecSimTieredIndex::debugInfo() const { .type = backendInfo.commonInfo.basicInfo.type, .isMulti = this->backendIndex->isMultiValue(), .isTiered = true, + .isDisk = backendInfo.commonInfo.basicInfo.isDisk, .blockSize = backendInfo.commonInfo.basicInfo.blockSize, .dim = backendInfo.commonInfo.basicInfo.dim, }; diff --git a/tests/unit/unit_test_utils.cpp b/tests/unit/unit_test_utils.cpp index 3c9a70ae6..5c79167f8 100644 --- a/tests/unit/unit_test_utils.cpp +++ b/tests/unit/unit_test_utils.cpp @@ -21,11 +21,11 @@ using float16 = vecsim_types::float16; // Map index types to their expected number of debug iterator fields namespace DebugInfoIteratorFieldCount { -constexpr size_t FLAT = 10; -constexpr size_t HNSW = 17; -constexpr size_t SVS = 24; -constexpr size_t TIERED_HNSW = 15; -constexpr size_t TIERED_SVS = 17; +constexpr size_t FLAT = 11; +constexpr size_t HNSW = 18; +constexpr size_t SVS = 25; +constexpr size_t TIERED_HNSW = 16; +constexpr size_t TIERED_SVS = 18; } // namespace DebugInfoIteratorFieldCount static void chooseCompareIndexInfoToIterator(VecSimIndexDebugInfo info, @@ -314,6 +314,10 @@ void compareFlatIndexInfoToIterator(VecSimIndexDebugInfo info, VecSimDebugInfoIt // Is the index multi value. ASSERT_EQ(infoField->fieldType, INFOFIELD_UINT64); ASSERT_EQ(infoField->fieldValue.uintegerValue, info.commonInfo.basicInfo.isMulti); + } else if (!strcmp(infoField->fieldName, VecSimCommonStrings::IS_DISK_STRING)) { + // Is the index disk-based. + ASSERT_EQ(infoField->fieldType, INFOFIELD_UINT64); + ASSERT_EQ(infoField->fieldValue.uintegerValue, info.commonInfo.basicInfo.isDisk); } else if (!strcmp(infoField->fieldName, VecSimCommonStrings::BLOCK_SIZE_STRING)) { // Block size. ASSERT_EQ(infoField->fieldType, INFOFIELD_UINT64); @@ -368,6 +372,10 @@ void compareHNSWIndexInfoToIterator(VecSimIndexDebugInfo info, VecSimDebugInfoIt // Is the index multi value. ASSERT_EQ(infoField->fieldType, INFOFIELD_UINT64); ASSERT_EQ(infoField->fieldValue.uintegerValue, info.commonInfo.basicInfo.isMulti); + } else if (!strcmp(infoField->fieldName, VecSimCommonStrings::IS_DISK_STRING)) { + // Is the index disk-based. + ASSERT_EQ(infoField->fieldType, INFOFIELD_UINT64); + ASSERT_EQ(infoField->fieldValue.uintegerValue, info.commonInfo.basicInfo.isDisk); } else if (!strcmp(infoField->fieldName, VecSimCommonStrings::HNSW_EF_CONSTRUCTION_STRING)) { // EF construction. @@ -464,6 +472,10 @@ void compareTieredIndexInfoToIterator(VecSimIndexDebugInfo info, // Is the index multi value. ASSERT_EQ(infoField->fieldType, INFOFIELD_UINT64); ASSERT_EQ(infoField->fieldValue.uintegerValue, info.commonInfo.basicInfo.isMulti); + } else if (!strcmp(infoField->fieldName, VecSimCommonStrings::IS_DISK_STRING)) { + // Is the index disk-based. + ASSERT_EQ(infoField->fieldType, INFOFIELD_UINT64); + ASSERT_EQ(infoField->fieldValue.uintegerValue, info.commonInfo.basicInfo.isDisk); } else if (!strcmp(infoField->fieldName, VecSimCommonStrings::MEMORY_STRING)) { // Memory. ASSERT_EQ(infoField->fieldType, INFOFIELD_UINT64); @@ -574,6 +586,10 @@ void compareSVSIndexInfoToIterator(VecSimIndexDebugInfo info, VecSimDebugInfoIte // Is the index multi value. ASSERT_EQ(infoField->fieldType, INFOFIELD_UINT64); ASSERT_EQ(infoField->fieldValue.uintegerValue, info.commonInfo.basicInfo.isMulti); + } else if (!strcmp(infoField->fieldName, VecSimCommonStrings::IS_DISK_STRING)) { + // Is the index disk-based. + ASSERT_EQ(infoField->fieldType, INFOFIELD_UINT64); + ASSERT_EQ(infoField->fieldValue.uintegerValue, info.commonInfo.basicInfo.isDisk); } else if (!strcmp(infoField->fieldName, VecSimCommonStrings::MEMORY_STRING)) { // Memory. ASSERT_EQ(infoField->fieldType, INFOFIELD_UINT64); @@ -726,10 +742,11 @@ std::vector getCommonFields() { VecSimCommonStrings::DIMENSION_STRING, // 2. DIMENSION VecSimCommonStrings::METRIC_STRING, // 3. METRIC VecSimCommonStrings::IS_MULTI_STRING, // 4. IS_MULTI - VecSimCommonStrings::INDEX_SIZE_STRING, // 5. INDEX_SIZE - VecSimCommonStrings::INDEX_LABEL_COUNT_STRING, // 6. INDEX_LABEL_COUNT - VecSimCommonStrings::MEMORY_STRING, // 7. MEMORY - VecSimCommonStrings::SEARCH_MODE_STRING // 8. SEARCH_MODE + VecSimCommonStrings::IS_DISK_STRING, // 5. IS_DISK + VecSimCommonStrings::INDEX_SIZE_STRING, // 6. INDEX_SIZE + VecSimCommonStrings::INDEX_LABEL_COUNT_STRING, // 7. INDEX_LABEL_COUNT + VecSimCommonStrings::MEMORY_STRING, // 8. MEMORY + VecSimCommonStrings::SEARCH_MODE_STRING // 9. SEARCH_MODE }; }