From 8b4bcf768bbe5e56a116f82cde653e069b468eb3 Mon Sep 17 00:00:00 2001 From: Jin Hai Date: Mon, 2 Mar 2020 12:15:26 +0800 Subject: [PATCH] Fix #839 and improve the code quality (#1470) * Fix #839 and improve the code quality Signed-off-by: JinHai-CN * Fix compiling error and building threads number Signed-off-by: JinHai-CN --- .codacy.yaml | 3 +++ ci/scripts/build.sh | 2 +- core/src/db/DBImpl.cpp | 8 ++++++-- core/src/db/DBImpl.h | 2 +- core/src/db/meta/MySQLConnectionPool.h | 4 ++-- core/src/db/wal/WalManager.cpp | 2 +- core/src/db/wal/WalManager.h | 2 +- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.codacy.yaml b/.codacy.yaml index 09d6cc45..6a2596d0 100644 --- a/.codacy.yaml +++ b/.codacy.yaml @@ -2,3 +2,6 @@ exclude_paths: - 'core/src/index/thirdparty/**' - 'sdk/build-support/**' - 'core/build-support/**' + - 'core/src/grpc/gen-milvus/**' + - 'core/src/grpc/gen-status/**' + - 'sdk/grpc-gen/**' diff --git a/ci/scripts/build.sh b/ci/scripts/build.sh index 0ac61589..30ea8249 100755 --- a/ci/scripts/build.sh +++ b/ci/scripts/build.sh @@ -144,7 +144,7 @@ if [[ ${RUN_CPPLINT} == "ON" ]]; then fi # compile and build -make -j8 || exit 1 +make -j6 || exit 1 if [[ ${PRIVILEGES} == "ON" ]];then sudo make install || exit 1 diff --git a/core/src/db/DBImpl.cpp b/core/src/db/DBImpl.cpp index 094247b8..98d8efc0 100644 --- a/core/src/db/DBImpl.cpp +++ b/core/src/db/DBImpl.cpp @@ -432,8 +432,12 @@ DBImpl::DropPartition(const std::string& partition_name) { return SHUTDOWN_ERROR; } - auto status = mem_mgr_->EraseMemVector(partition_name); // not allow insert - status = meta_ptr_->DropPartition(partition_name); // soft delete table + mem_mgr_->EraseMemVector(partition_name); // not allow insert + auto status = meta_ptr_->DropPartition(partition_name); // soft delete table + if (!status.ok()) { + ENGINE_LOG_ERROR << status.message(); + return status; + } // scheduler will determine when to delete table files auto nres = scheduler::ResMgrInst::GetInstance()->GetNumOfComputeResource(); diff --git a/core/src/db/DBImpl.h b/core/src/db/DBImpl.h index 42413c28..a8e9bb14 100644 --- a/core/src/db/DBImpl.h +++ b/core/src/db/DBImpl.h @@ -74,7 +74,7 @@ class DBImpl : public DB { PreloadTable(const std::string& table_id) override; Status - UpdateTableFlag(const std::string& table_id, int64_t flag); + UpdateTableFlag(const std::string& table_id, int64_t flag) override; Status GetTableRowCount(const std::string& table_id, uint64_t& row_count) override; diff --git a/core/src/db/meta/MySQLConnectionPool.h b/core/src/db/meta/MySQLConnectionPool.h index 06975ea2..02378126 100644 --- a/core/src/db/meta/MySQLConnectionPool.h +++ b/core/src/db/meta/MySQLConnectionPool.h @@ -24,8 +24,8 @@ namespace meta { class MySQLConnectionPool : public mysqlpp::ConnectionPool { public: // The object's only constructor - MySQLConnectionPool(std::string dbName, std::string userName, std::string passWord, std::string serverIp, - int port = 0, int maxPoolSize = 8) + MySQLConnectionPool(const std::string& dbName, const std::string& userName, const std::string& passWord, + const std::string& serverIp, int port = 0, int maxPoolSize = 8) : db_(dbName), user_(userName), password_(passWord), diff --git a/core/src/db/wal/WalManager.cpp b/core/src/db/wal/WalManager.cpp index 0eebb031..60a103c9 100644 --- a/core/src/db/wal/WalManager.cpp +++ b/core/src/db/wal/WalManager.cpp @@ -341,7 +341,7 @@ WalManager::DeleteById(const std::string& table_id, const IDNumbers& vector_ids) } uint64_t -WalManager::Flush(const std::string table_id) { +WalManager::Flush(const std::string& table_id) { std::lock_guard lck(mutex_); // At most one flush requirement is waiting at any time. // Otherwise, flush_info_ should be modified to a list. diff --git a/core/src/db/wal/WalManager.h b/core/src/db/wal/WalManager.h index 3b2d3f0a..67bcf4cc 100644 --- a/core/src/db/wal/WalManager.h +++ b/core/src/db/wal/WalManager.h @@ -107,7 +107,7 @@ class WalManager { * else, return 0 */ uint64_t - Flush(const std::string table_id = ""); + Flush(const std::string& table_id = ""); void RemoveOldFiles(uint64_t flushed_lsn); -- GitLab