diff --git a/internal/core/src/index/IndexFactory.cpp b/internal/core/src/index/IndexFactory.cpp index 4a594725ec..90862dffdc 100644 --- a/internal/core/src/index/IndexFactory.cpp +++ b/internal/core/src/index/IndexFactory.cpp @@ -308,7 +308,8 @@ IndexFactory::ScalarIndexLoadResource( request.max_disk_cost = 0; } request.has_raw_data = true; - } else if (index_type == milvus::index::INVERTED_INDEX_TYPE) { + } else if (index_type == milvus::index::INVERTED_INDEX_TYPE || + index_type == milvus::index::NGRAM_INDEX_TYPE) { request.final_memory_cost = 0; request.final_disk_cost = index_size_in_bytes; request.max_memory_cost = index_size_in_bytes; diff --git a/internal/core/src/index/NgramInvertedIndexTest.cpp b/internal/core/src/index/NgramInvertedIndexTest.cpp index 04279fbc40..e1b9b03ed4 100644 --- a/internal/core/src/index/NgramInvertedIndexTest.cpp +++ b/internal/core/src/index/NgramInvertedIndexTest.cpp @@ -99,6 +99,7 @@ test_ngram_with_data(const boost::container::vector& data, storage::FileManagerContext ctx(field_meta, index_meta, cm); std::vector index_files; + auto index_size = 0; { Config config; config[milvus::index::INDEX_TYPE] = milvus::index::INVERTED_INDEX_TYPE; @@ -115,9 +116,9 @@ test_ngram_with_data(const boost::container::vector& data, auto create_index_result = index->Upload(); auto memSize = create_index_result->GetMemSize(); - auto serializedSize = create_index_result->GetSerializedSize(); + index_size = create_index_result->GetSerializedSize(); ASSERT_GT(memSize, 0); - ASSERT_GT(serializedSize, 0); + ASSERT_GT(index_size, 0); index_files = create_index_result->GetIndexFiles(); } @@ -183,7 +184,7 @@ test_ngram_with_data(const boost::container::vector& data, .index_params = index_params, .index_files = index_files, .schema = field_meta.field_schema, - .index_size = 1024 * 1024 * 1024, + .index_size = index_size, }; uint8_t trace_id[16] = {0}; diff --git a/internal/core/unittest/test_loading.cpp b/internal/core/unittest/test_loading.cpp index 6c59232acd..f7e2c47b62 100644 --- a/internal/core/unittest/test_loading.cpp +++ b/internal/core/unittest/test_loading.cpp @@ -239,6 +239,24 @@ INSTANTIATE_TEST_SUITE_P( 0, 1 * 1024 * 1024 * 1024, false}), + std::pair, LoadResourceRequest>( + {{"index_type", "NGRAM"}, + {"mmap", "false"}, + {"field_type", "string"}}, + {1UL * 1024 * 1024 * 1024, + 1UL * 1024 * 1024 * 1024, + 0UL, + 1UL * 1024 * 1024 * 1024, + false}), + std::pair, LoadResourceRequest>( + {{"index_type", "NGRAM"}, + {"mmap", "true"}, + {"field_type", "string"}}, + {1 * 1024 * 1024 * 1024, + 1 * 1024 * 1024 * 1024, + 0, + 1 * 1024 * 1024 * 1024, + false}), std::pair, LoadResourceRequest>( {{"index_type", "BITMAP"}, {"mmap", "false"},