fix: load resource considers ngram index (#44237)

fix https://github.com/milvus-io/milvus/issues/44236

---------

Signed-off-by: SpadeA <tangchenjie1210@gmail.com>
This commit is contained in:
Spade A 2025-09-10 10:27:56 +08:00 committed by GitHub
parent 26a024625d
commit 45adf2d426
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 4 deletions

View File

@ -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;

View File

@ -99,6 +99,7 @@ test_ngram_with_data(const boost::container::vector<std::string>& data,
storage::FileManagerContext ctx(field_meta, index_meta, cm);
std::vector<std::string> 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<std::string>& 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<std::string>& 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};

View File

@ -239,6 +239,24 @@ INSTANTIATE_TEST_SUITE_P(
0,
1 * 1024 * 1024 * 1024,
false}),
std::pair<std::map<std::string, std::string>, 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<std::map<std::string, std::string>, 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<std::map<std::string, std::string>, LoadResourceRequest>(
{{"index_type", "BITMAP"},
{"mmap", "false"},