From 2b1240e250b6d340fca30a334755e41ceba2635e Mon Sep 17 00:00:00 2001 From: starlord Date: Wed, 9 Oct 2019 14:17:17 +0800 Subject: [PATCH] refine code Former-commit-id: dea5807b12170595c45d402802b5a88fecf24b57 --- cpp/src/scheduler/optimizer/HybridPass.cpp | 10 +++++----- cpp/src/scheduler/optimizer/HybridPass.h | 19 +++++++++---------- cpp/src/scheduler/optimizer/Optimizer.cpp | 7 +++---- cpp/src/scheduler/optimizer/Optimizer.h | 21 ++++++++++----------- cpp/src/scheduler/optimizer/Pass.h | 21 +++++++++++---------- cpp/src/server/Config.cpp | 12 ++++-------- cpp/src/server/DBWrapper.cpp | 13 +++++++------ cpp/src/server/DBWrapper.h | 1 + 8 files changed, 50 insertions(+), 54 deletions(-) diff --git a/cpp/src/scheduler/optimizer/HybridPass.cpp b/cpp/src/scheduler/optimizer/HybridPass.cpp index 1b0ab7c4..f172a7be 100644 --- a/cpp/src/scheduler/optimizer/HybridPass.cpp +++ b/cpp/src/scheduler/optimizer/HybridPass.cpp @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -#include "HybridPass.h" +#include "scheduler/optimizer/HybridPass.h" #include "scheduler/task/SearchTask.h" namespace milvus { @@ -24,12 +24,12 @@ namespace scheduler { bool HybridPass::Run(const TaskPtr& task) { // TODO: Index::IVFSQ8Hybrid, if nq < threshold set cpu, else set gpu - if (task->Type() != TaskType::SearchTask) return false; + if (task->Type() != TaskType::SearchTask) + return false; auto search_task = std::static_pointer_cast(task); // if (search_task->file_->engine_type_ == engine::EngineType::FAISS_IVFSQ8Hybrid) return false; } -} -} - +} // namespace scheduler +} // namespace milvus diff --git a/cpp/src/scheduler/optimizer/HybridPass.h b/cpp/src/scheduler/optimizer/HybridPass.h index e043bf8a..0d02a8bd 100644 --- a/cpp/src/scheduler/optimizer/HybridPass.h +++ b/cpp/src/scheduler/optimizer/HybridPass.h @@ -16,16 +16,16 @@ // under the License. #pragma once -#include -#include +#include +#include #include +#include +#include #include -#include -#include +#include #include -#include -#include -#include +#include +#include #include "Pass.h" @@ -43,6 +43,5 @@ class HybridPass : public Pass { using HybridPassPtr = std::shared_ptr; -} -} - +} // namespace scheduler +} // namespace milvus diff --git a/cpp/src/scheduler/optimizer/Optimizer.cpp b/cpp/src/scheduler/optimizer/Optimizer.cpp index 517cd85f..c5fa311a 100644 --- a/cpp/src/scheduler/optimizer/Optimizer.cpp +++ b/cpp/src/scheduler/optimizer/Optimizer.cpp @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -#include "Optimizer.h" +#include "scheduler/optimizer/Optimizer.h" namespace milvus { namespace scheduler { @@ -38,6 +38,5 @@ Optimizer::Run(const TaskPtr& task) { return false; } -} -} - +} // namespace scheduler +} // namespace milvus diff --git a/cpp/src/scheduler/optimizer/Optimizer.h b/cpp/src/scheduler/optimizer/Optimizer.h index cbb13a8f..99282e66 100644 --- a/cpp/src/scheduler/optimizer/Optimizer.h +++ b/cpp/src/scheduler/optimizer/Optimizer.h @@ -16,16 +16,16 @@ // under the License. #pragma once -#include -#include +#include +#include #include +#include +#include #include -#include -#include +#include #include -#include -#include -#include +#include +#include #include "Pass.h" @@ -40,12 +40,11 @@ class Optimizer { Init(); bool - Run(const TaskPtr &task); + Run(const TaskPtr& task); private: std::vector pass_list_; }; -} -} - +} // namespace scheduler +} // namespace milvus diff --git a/cpp/src/scheduler/optimizer/Pass.h b/cpp/src/scheduler/optimizer/Pass.h index 1c8def41..959c3ea5 100644 --- a/cpp/src/scheduler/optimizer/Pass.h +++ b/cpp/src/scheduler/optimizer/Pass.h @@ -16,16 +16,16 @@ // under the License. #pragma once -#include -#include +#include +#include #include +#include +#include #include -#include -#include +#include #include -#include -#include -#include +#include +#include #include "scheduler/task/Task.h" @@ -35,12 +35,13 @@ namespace scheduler { class Pass { public: virtual void - Init() {} + Init() { + } virtual bool Run(const TaskPtr& task) = 0; }; using PassPtr = std::shared_ptr; -} -} +} // namespace scheduler +} // namespace milvus diff --git a/cpp/src/server/Config.cpp b/cpp/src/server/Config.cpp index 3a88c7f8..d383eb5e 100644 --- a/cpp/src/server/Config.cpp +++ b/cpp/src/server/Config.cpp @@ -735,8 +735,7 @@ Config::GetDBConfigArchiveDaysThreshold(int32_t& value) { Status Config::GetDBConfigInsertBufferSize(int32_t& value) { - std::string str = - GetConfigStr(CONFIG_DB, CONFIG_DB_INSERT_BUFFER_SIZE, CONFIG_DB_INSERT_BUFFER_SIZE_DEFAULT); + std::string str = GetConfigStr(CONFIG_DB, CONFIG_DB_INSERT_BUFFER_SIZE, CONFIG_DB_INSERT_BUFFER_SIZE_DEFAULT); Status s = CheckDBConfigInsertBufferSize(str); if (!s.ok()) { return s; @@ -748,8 +747,7 @@ Config::GetDBConfigInsertBufferSize(int32_t& value) { Status Config::GetDBConfigBuildIndexGPU(int32_t& value) { - std::string str = - GetConfigStr(CONFIG_DB, CONFIG_DB_BUILD_INDEX_GPU, CONFIG_DB_BUILD_INDEX_GPU_DEFAULT); + std::string str = GetConfigStr(CONFIG_DB, CONFIG_DB_BUILD_INDEX_GPU, CONFIG_DB_BUILD_INDEX_GPU_DEFAULT); Status s = CheckDBConfigBuildIndexGPU(str); if (!s.ok()) { return s; @@ -767,8 +765,7 @@ Config::GetDBConfigPreloadTable(std::string& value) { Status Config::GetMetricConfigEnableMonitor(bool& value) { - std::string str = - GetConfigStr(CONFIG_METRIC, CONFIG_METRIC_ENABLE_MONITOR, CONFIG_METRIC_ENABLE_MONITOR_DEFAULT); + std::string str = GetConfigStr(CONFIG_METRIC, CONFIG_METRIC_ENABLE_MONITOR, CONFIG_METRIC_ENABLE_MONITOR_DEFAULT); Status s = CheckMetricConfigEnableMonitor(str); if (!s.ok()) { return s; @@ -872,8 +869,7 @@ Config::GetEngineConfigUseBlasThreshold(int32_t& value) { Status Config::GetEngineConfigOmpThreadNum(int32_t& value) { - std::string str = - GetConfigStr(CONFIG_ENGINE, CONFIG_ENGINE_OMP_THREAD_NUM, CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT); + std::string str = GetConfigStr(CONFIG_ENGINE, CONFIG_ENGINE_OMP_THREAD_NUM, CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT); Status s = CheckEngineConfigOmpThreadNum(str); if (!s.ok()) { return s; diff --git a/cpp/src/server/DBWrapper.cpp b/cpp/src/server/DBWrapper.cpp index 99bf57b3..306863f8 100644 --- a/cpp/src/server/DBWrapper.cpp +++ b/cpp/src/server/DBWrapper.cpp @@ -25,6 +25,7 @@ #include #include #include +#include namespace milvus { namespace server { @@ -183,14 +184,14 @@ DBWrapper::StopService() { Status DBWrapper::PreloadTables(const std::string& preload_tables) { - if(preload_tables.empty()) { - //do nothing - } else if(preload_tables == "*") { - //load all tables + if (preload_tables.empty()) { + // do nothing + } else if (preload_tables == "*") { + // load all tables std::vector table_schema_array; db_->AllTables(table_schema_array); - for(auto& schema : table_schema_array) { + for (auto& schema : table_schema_array) { auto status = db_->PreloadTable(schema.table_id_); if (!status.ok()) { return status; @@ -199,7 +200,7 @@ DBWrapper::PreloadTables(const std::string& preload_tables) { } else { std::vector table_names; StringHelpFunctions::SplitStringByDelimeter(preload_tables, ",", table_names); - for(auto& name : table_names) { + for (auto& name : table_names) { auto status = db_->PreloadTable(name); if (!status.ok()) { return status; diff --git a/cpp/src/server/DBWrapper.h b/cpp/src/server/DBWrapper.h index 3508efa6..7016aa88 100644 --- a/cpp/src/server/DBWrapper.h +++ b/cpp/src/server/DBWrapper.h @@ -21,6 +21,7 @@ #include "utils/Status.h" #include +#include namespace milvus { namespace server { -- GitLab