From 4e59f966c300854a86d82955eecce83f88479189 Mon Sep 17 00:00:00 2001 From: Xu Peng Date: Wed, 24 Apr 2019 16:04:14 +0800 Subject: [PATCH] feat(db): cache for mem merge Former-commit-id: bff342710683954dcd4b72b890fff483708ceba0 --- cpp/src/db/DBImpl.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cpp/src/db/DBImpl.cpp b/cpp/src/db/DBImpl.cpp index 2115c637..81a0bb1c 100644 --- a/cpp/src/db/DBImpl.cpp +++ b/cpp/src/db/DBImpl.cpp @@ -214,7 +214,11 @@ Status DBImpl::merge_files(const std::string& group_id, const meta::DateT& date, meta::GroupFilesSchema updated; for (auto& file : files) { - auto file_index = dynamic_cast(faiss::read_index(file.location.c_str())); + auto to_merge = zilliz::vecwise::cache::CpuCacheMgr::GetInstance()->GetIndex(file.location); + if (!to_merge) { + to_merge = read_index(file.location.c_str()); + } + auto file_index = dynamic_cast(to_merge->data().get()); index->add_with_ids(file_index->ntotal, dynamic_cast(file_index->index)->xb.data(), file_index->id_map.data()); auto file_schema = file; @@ -222,7 +226,6 @@ Status DBImpl::merge_files(const std::string& group_id, const meta::DateT& date, updated.push_back(file_schema); LOG(DEBUG) << "About to merge file " << file_schema.file_id << " of size=" << file_schema.rows; - delete file_index; } auto index_size = group_file.dimension * index->ntotal; -- GitLab