From 08ec4e31b6fb633e19300fdd4c26ec02f321290b Mon Sep 17 00:00:00 2001 From: yixinglu <2520865+yixinglu@users.noreply.github.com> Date: Fri, 8 Oct 2021 07:15:39 +0800 Subject: [PATCH] Address comments --- src/graph/service/QueryEngine.cpp | 15 +++++---------- src/graph/service/QueryEngine.h | 11 +++++------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/graph/service/QueryEngine.cpp b/src/graph/service/QueryEngine.cpp index 6c9bb2b2b35..674d5bb0329 100644 --- a/src/graph/service/QueryEngine.cpp +++ b/src/graph/service/QueryEngine.cpp @@ -41,7 +41,7 @@ Status QueryEngine::init(std::shared_ptr ioExecutor } optimizer_ = std::make_unique(rulesets); - return setupBackgroundThread(); + return setupMemoryMonitorThread(); } void QueryEngine::execute(RequestContextPtr rctx) { @@ -55,9 +55,9 @@ void QueryEngine::execute(RequestContextPtr rctx) { instance->execute(); } -Status QueryEngine::setupBackgroundThread() { - bgThread_ = std::make_unique(); - if (!bgThread_ || !bgThread_->start("query-engine-bg")) { +Status QueryEngine::setupMemoryMonitorThread() { + memoryMonitorThread_ = std::make_unique(); + if (!memoryMonitorThread_ || !memoryMonitorThread_->start("query-engine-bg")) { return Status::Error("Fail to start query engine background thread."); } @@ -71,12 +71,7 @@ Status QueryEngine::setupBackgroundThread() { // Just to test whether to get the right memory info NG_RETURN_IF_ERROR(updateMemoryWatermark()); - bgThread_->addRepeatTask(FLAGS_check_memory_interval_in_secs, [updateMemoryWatermark]() { - auto status = updateMemoryWatermark(); - if (!status.ok()) { - LOG(ERROR) << status; - } - }); + memoryMonitorThread_->addRepeatTask(FLAGS_check_memory_interval_in_secs, updateMemoryWatermark return Status::OK(); } diff --git a/src/graph/service/QueryEngine.h b/src/graph/service/QueryEngine.h index 39e5e342f84..66efd23cb5f 100644 --- a/src/graph/service/QueryEngine.h +++ b/src/graph/service/QueryEngine.h @@ -20,15 +20,14 @@ #include "graph/service/RequestContext.h" #include "interface/gen-cpp2/GraphService.h" +namespace nebula { +namespace graph { + /** * QueryEngine is responsible to create and manage ExecutionPlan. * For the time being, we don't have the execution plan cache support, * instead we create a plan for each query, and destroy it upon finish. */ - -namespace nebula { -namespace graph { - class QueryEngine final : public cpp::NonCopyable, public cpp::NonMovable { public: QueryEngine() = default; @@ -43,13 +42,13 @@ class QueryEngine final : public cpp::NonCopyable, public cpp::NonMovable { const meta::MetaClient* metaClient() const { return metaClient_; } private: - Status setupBackgroundThread(); + Status setupMemoryMonitorThread(); std::unique_ptr schemaManager_; std::unique_ptr indexManager_; std::unique_ptr storage_; std::unique_ptr optimizer_; - std::unique_ptr bgThread_; + std::unique_ptr memoryMonitorThread_; meta::MetaClient* metaClient_{nullptr}; CharsetInfo* charsetInfo_{nullptr}; };