From ac7e3beeba420d3fa04a9e2e875cc73f003e23d1 Mon Sep 17 00:00:00 2001 From: groot Date: Thu, 27 Jun 2019 11:56:43 +0800 Subject: [PATCH 1/2] archive config Former-commit-id: b15e120d31fae469af9171c5d3da33f7cdaeb2bd --- cpp/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index ca4e466cf9..45c3f18d75 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -21,6 +21,8 @@ Please mark all change in change log and use the ticket from JIRA. - MS-92 - Unify behavior of debug and release build - MS-98 - Install all unit test to installation directory - MS-115 - Change is_startup of metric_config switch from true to on +- MS-122 - Archive criteria config + ## New Feature - MS-57 - Implement index load/search pipeline From 1d8d1d3e7783c3868ff872fa5111b7c1ab33bad6 Mon Sep 17 00:00:00 2001 From: groot Date: Thu, 27 Jun 2019 14:45:53 +0800 Subject: [PATCH 2/2] fix portential bug Former-commit-id: f0a5eed0de7e85c6db7b8b36e9751185b531d5ea --- cpp/src/db/MemManager.cpp | 24 +++++++++++++++++++++--- cpp/src/db/MemManager.h | 2 ++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cpp/src/db/MemManager.cpp b/cpp/src/db/MemManager.cpp index fa7f3c54b0..e36b0c45ba 100644 --- a/cpp/src/db/MemManager.cpp +++ b/cpp/src/db/MemManager.cpp @@ -146,11 +146,16 @@ Status MemManager::InsertVectorsNoLock(const std::string& table_id, Status MemManager::ToImmutable() { std::unique_lock lock(mutex_); + MemIdMap temp_map; for (auto& kv: mem_id_map_) { + if(kv.second->RowCount() == 0) { + temp_map.insert(kv); + continue;//empty vector, no need to serialize + } immu_mem_list_.push_back(kv.second); } - mem_id_map_.clear(); + mem_id_map_.swap(temp_map); return Status::OK(); } @@ -168,8 +173,21 @@ Status MemManager::Serialize(std::set& table_ids) { } Status MemManager::EraseMemVector(const std::string& table_id) { - std::unique_lock lock(mutex_); - mem_id_map_.erase(table_id); + {//erase MemVector from rapid-insert cache + std::unique_lock lock(mutex_); + mem_id_map_.erase(table_id); + } + + {//erase MemVector from serialize cache + std::unique_lock lock(serialization_mtx_); + MemList temp_list; + for (auto& mem : immu_mem_list_) { + if(mem->TableId() != table_id) { + temp_list.push_back(mem); + } + } + immu_mem_list_.swap(temp_list); + } return Status::OK(); } diff --git a/cpp/src/db/MemManager.h b/cpp/src/db/MemManager.h index 2aa0183898..0ce88d504d 100644 --- a/cpp/src/db/MemManager.h +++ b/cpp/src/db/MemManager.h @@ -45,6 +45,8 @@ public: const std::string& Location() const { return schema_.location_; } + std::string TableId() const { return schema_.table_id_; } + private: MemVectors() = delete; MemVectors(const MemVectors&) = delete;