From fe88a243d1050fc65fdc86c4ff5c481d6023f5b2 Mon Sep 17 00:00:00 2001 From: zhagnlu <1542303831@qq.com> Date: Wed, 9 Apr 2025 10:14:27 +0800 Subject: [PATCH] fix: fix remove index type failed when remote storage is local mode (#41163) pr: #41164 Signed-off-by: luzhang Co-authored-by: luzhang --- .../core/src/index/InvertedIndexTantivy.cpp | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/internal/core/src/index/InvertedIndexTantivy.cpp b/internal/core/src/index/InvertedIndexTantivy.cpp index caafa1b55a..7ed8ddcb32 100644 --- a/internal/core/src/index/InvertedIndexTantivy.cpp +++ b/internal/core/src/index/InvertedIndexTantivy.cpp @@ -178,24 +178,26 @@ InvertedIndexTantivy::Load(milvus::tracer::TraceContext ctx, auto inverted_index_files = index_files.value(); // need erase the index type file that has been readed - auto index_type_file = - disk_file_manager_->GetRemoteIndexPrefix() + std::string("/index_type"); - inverted_index_files.erase( - std::remove_if( - inverted_index_files.begin(), - inverted_index_files.end(), - [&](const std::string& file) { return file == index_type_file; }), - inverted_index_files.end()); + auto GetFileName = [](const std::string& path) -> std::string { + auto pos = path.find_last_of('/'); + return pos == std::string::npos ? path : path.substr(pos + 1); + }; + inverted_index_files.erase(std::remove_if(inverted_index_files.begin(), + inverted_index_files.end(), + [&](const std::string& file) { + return GetFileName(file) == + "index_type"; + }), + inverted_index_files.end()); std::vector null_offset_files; std::shared_ptr null_offset_data; - auto find_file = [&](const std::string& file) -> auto { + auto find_file = [&](const std::string& target) -> auto { return std::find_if(inverted_index_files.begin(), inverted_index_files.end(), - [&](const std::string& f) { - return f.substr(f.find_last_of('/') + 1) == - file; + [&](const std::string& filename) { + return GetFileName(filename) == target; }); };