From ce8219f1a3f5cc7a42b44f3ed3bf2ec1967079e4 Mon Sep 17 00:00:00 2001 From: yah01 Date: Thu, 30 Nov 2023 21:10:32 +0800 Subject: [PATCH] fix: bypass growing index if no index meta (#28791) (#28859) we shouldn't panic if no index meta, just skip building it fix #28022 pr: #28791 --------- Signed-off-by: yah01 --- internal/core/src/segcore/FieldIndexing.h | 8 ++++++++ internal/core/unittest/test_growing_index.cpp | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/internal/core/src/segcore/FieldIndexing.h b/internal/core/src/segcore/FieldIndexing.h index cee451fe99..c894c335ab 100644 --- a/internal/core/src/segcore/FieldIndexing.h +++ b/internal/core/src/segcore/FieldIndexing.h @@ -11,6 +11,7 @@ #pragma once +#include #include #include #include @@ -24,6 +25,7 @@ #include "common/Schema.h" #include "common/IndexMeta.h" #include "IndexConfigGenerator.h" +#include "log/Log.h" #include "segcore/SegcoreConfig.h" #include "index/VectorIndex.h" @@ -248,6 +250,12 @@ class IndexingRecord { if (field_meta.get_data_type() == DataType::VECTOR_BINARY) { continue; } + + if (index_meta_ == nullptr) { + LOG_SEGCORE_INFO_ + << "miss index meta for growing interim index"; + continue; + } //Small-Index enabled, create index for vector field only if (index_meta_->GetIndexMaxRowCount() > 0 && index_meta_->HasFiled(field_id)) { diff --git a/internal/core/unittest/test_growing_index.cpp b/internal/core/unittest/test_growing_index.cpp index fa612fc31c..8a690d96a7 100644 --- a/internal/core/unittest/test_growing_index.cpp +++ b/internal/core/unittest/test_growing_index.cpp @@ -125,6 +125,20 @@ TEST(GrowingIndex, Correctness) { } } +TEST(GrowingIndex, MissIndexMeta) { + auto schema = std::make_shared(); + auto pk = schema->AddDebugField("pk", DataType::INT64); + auto random = schema->AddDebugField("random", DataType::DOUBLE); + auto vec = schema->AddDebugField( + "embeddings", DataType::VECTOR_FLOAT, 128, knowhere::metric::L2); + schema->set_primary_field_id(pk); + + auto& config = SegcoreConfig::default_config(); + config.set_chunk_rows(1024); + config.set_enable_growing_segment_index(true); + auto segment = CreateGrowingSegment(schema, nullptr); +} + using Param = const char*; class GrowingIndexGetVectorTest : public ::testing::TestWithParam {