diff --git a/CMakeLists.txt b/CMakeLists.txt index 702043321b0c50de8dd3394726e72355a8504fab..55b58ca63f57c29c21f348c9dca6a0bbd42ff175 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,11 @@ set(NEBULA_HOME ${CMAKE_CURRENT_SOURCE_DIR}) add_definitions(-DNEBULA_HOME=${NEBULA_HOME}) # To include customized FindXXX.cmake modules -set(CMAKE_MODULE_PATH "${NEBULA_HOME}/modules/common/" "${NEBULA_HOME}/cmake" "${NEBULA_HOME}/modules/common/cmake" ${CMAKE_MODULE_PATH}) +set(CMAKE_MODULE_PATH + "${NEBULA_HOME}/cmake" + "${NEBULA_HOME}/modules/common/" + "${NEBULA_HOME}/modules/common/cmake" + ${CMAKE_MODULE_PATH}) find_package(Git) if (GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") @@ -68,17 +72,16 @@ include(AddDependentProject) message(STATUS "") message(STATUS ">>>>> Configuring the nebula-common repo <<<<<") add_dependent_project( - ${NEBULA_HOME}/modules - common - ${NEBULA_COMMON_REPO_URL} - ${NEBULA_COMMON_REPO_TAG} + BASE ${NEBULA_HOME}/modules + NAME common + REPO ${NEBULA_COMMON_REPO_URL} + TAG ${NEBULA_COMMON_REPO_TAG} ) find_package(${NEBULA_COMMON_PACKAGE} REQUIRED) message(STATUS ">>>>> The nebula-common repo has been configured successfully <<<<<") message(STATUS "") if(ENABLE_BUILD_STORAGE) - if("${NEBULA_STORAGE_REPO_URL}" STREQUAL "") SET(NEBULA_STORAGE_REPO_URL "git@github.com:vesoft-inc-private/nebula-storage.git") endif() @@ -87,19 +90,19 @@ if(ENABLE_BUILD_STORAGE) SET(NEBULA_STORAGE_REPO_TAG "master") endif() - SET(NEBULA_COMMON_PACKAGE "nebula-storage") + SET(NEBULA_STORAGE_PACKAGE "nebula-storage") SET(nebula-storage_DIR ${CMAKE_CURRENT_SOURCE_DIR}/modules/storage) # Configure the dependent projects message(STATUS "") message(STATUS ">>>>> Configuring the nebula-storage repo <<<<<") add_dependent_project( - ${NEBULA_HOME}/modules - storage - ${NEBULA_STORAGE_REPO_URL} - ${NEBULA_STORAGE_REPO_TAG} + BASE ${NEBULA_HOME}/modules + NAME storage + REPO ${NEBULA_STORAGE_REPO_URL} + TAG ${NEBULA_STORAGE_REPO_TAG} + -DNEBULA_COMMON_PATH=${nebula-common_DIR} ) - find_package(${NEBULA_STORAGE_PACKAGE} REQUIRED) message(STATUS ">>>>> The nebula-storage repo has been configured successfully <<<<<") message(STATUS "") endif() diff --git a/cmake/AddDependentProject.cmake b/cmake/AddDependentProject.cmake index e962d86b8ba7a890c41e96d46624ba5b249f79d0..d2f0881679da27d85a0cefcdf9b956688bff6510 100644 --- a/cmake/AddDependentProject.cmake +++ b/cmake/AddDependentProject.cmake @@ -4,67 +4,73 @@ # attached with Common Clause Condition 1.0, found in the LICENSES directory. # -macro(add_dependent_project base name repo tag) - -# Clone or update the repo -if(EXISTS ${base}/${name}/.git) - message(STATUS "Updating from the repo \"" ${repo} "\"") - execute_process( - COMMAND ${GIT_EXECUTABLE} pull --depth=1 - WORKING_DIRECTORY ${base}/${name} - RESULT_VARIABLE clone_result +macro(add_dependent_project) + cmake_parse_arguments( + DEP_PROJ # prefix + "" # <options> + "BASE;NAME;REPO;TAG" # <one_value_args> + "" # <multi_value_args> + ${ARGN} ) -else() - message(STATUS "Cloning from the repo \"" ${repo} "\"") + + set(CLONE_DIR ${DEP_PROJ_BASE}/${DEP_PROJ_NAME}) + # Clone or update the repo + if(EXISTS ${CLONE_DIR}/.git) + message(STATUS "Updating from the repo \"" ${DEP_PROJ_REPO} "\"") + execute_process( + COMMAND ${GIT_EXECUTABLE} pull --depth=1 + WORKING_DIRECTORY ${CLONE_DIR} + RESULT_VARIABLE clone_result + ) + else() + message(STATUS "Cloning from the repo \"" ${DEP_PROJ_REPO} "\"") + execute_process( + COMMAND ${GIT_EXECUTABLE} clone + --depth 1 + --progress + --single-branch + --branch ${DEP_PROJ_TAG} + ${DEP_PROJ_REPO} + ${CLONE_DIR} + RESULT_VARIABLE clone_result + ) + endif() + + if(NOT ${clone_result} EQUAL 0) + message(FATAL_ERROR "Cannot clone the repo from \"${DEP_PROJ_REPO}\" (branch \"${DEP_PROJ_TAG}\"): \"${clone_result}\"") + else() + message(STATUS "Updated the repo from \"${DEP_PROJ_REPO}\" (branch \"${DEP_PROJ_TAG}\")") + endif() + + # Configure the repo execute_process( COMMAND - ${GIT_EXECUTABLE} clone --depth 1 --progress --single-branch --branch ${tag} ${repo} ${base}/${name} - RESULT_VARIABLE clone_result + ${CMAKE_COMMAND} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DNEBULA_THIRDPARTY_ROOT=${NEBULA_THIRDPARTY_ROOT} + -DNEBULA_OTHER_ROOT=${NEBULA_OTHER_ROOT} + -DENABLE_JEMALLOC=${ENABLE_JEMALLOC} + -DENABLE_NATIVE=${ENABLE_NATIVE} + -DENABLE_TESTING=false + -DENABLE_CCACHE=${ENABLE_CCACHE} + -DENABLE_ASAN=${ENABLE_ASAN} + -DENABLE_UBSAN=${ENABLE_UBSAN} + ${DEP_PROJ_UNPARSED_ARGUMENTS} + . + WORKING_DIRECTORY ${CLONE_DIR} + RESULT_VARIABLE cmake_result ) -endif() - -if(NOT ${clone_result} EQUAL 0) - message( - FATAL_ERROR - "Cannot clone the repo from \"" - ${repo} - "\" (branch \"" - ${tag} - "\"): \"" - ${clone_result} - "\"") -else() - message(STATUS "Updated the repo from \"" ${repo} "\" (branch \"" ${tag} "\")") -endif() + if(NOT ${cmake_result} EQUAL 0) + message(FATAL_ERROR "Failed to configure the dependent project \"" ${DEP_PROJ_NAME} "\"") + endif() -# Configure the repo -execute_process( - COMMAND - ${CMAKE_COMMAND} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DNEBULA_THIRDPARTY_ROOT=${NEBULA_THIRDPARTY_ROOT} - -DNEBULA_OTHER_ROOT=${NEBULA_OTHER_ROOT} - -DENABLE_JEMALLOC=${ENABLE_JEMALLOC} - -DENABLE_NATIVE=${ENABLE_NATIVE} - -DENABLE_TESTING=false - -DENABLE_CCACHE=${ENABLE_CCACHE} - -DENABLE_ASAN=${ENABLE_ASAN} - -DENABLE_UBSAN=${ENABLE_UBSAN} - . - WORKING_DIRECTORY ${base}/${name} - RESULT_VARIABLE cmake_result -) -if(NOT ${cmake_result} EQUAL 0) - message(FATAL_ERROR "Failed to configure the dependent project \"" ${name} "\"") -endif() - -# Add a custom target to build the project -add_custom_target( - ${name}_project ALL - COMMAND make -j - WORKING_DIRECTORY ${base}/${name} -) + # Add a custom target to build the project + add_custom_target( + ${DEP_PROJ_NAME}_project ALL + COMMAND make -j $(nproc) + WORKING_DIRECTORY ${CLONE_DIR} + ) endmacro() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 541c00c38f762be65bd96966b65fba99f0eedf65..f62da9c0606ff8a6d24761da57f707c9b385f894 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,4 +13,4 @@ nebula_add_subdirectory(exec) nebula_add_subdirectory(util) nebula_add_subdirectory(mock) nebula_add_subdirectory(context) -nebula_add_subdirectory(schedule) +nebula_add_subdirectory(scheduler) diff --git a/src/context/ExecutionContext.h b/src/context/ExecutionContext.h index 5827d7e36f90c7016bd86f7260f29b184356f702..af7a577bc05054ed671e0c569bed42e8e4f63002 100644 --- a/src/context/ExecutionContext.h +++ b/src/context/ExecutionContext.h @@ -14,6 +14,8 @@ namespace nebula { namespace graph { +class QueryInstance; + /*************************************************************************** * * The context for each query request @@ -40,8 +42,6 @@ public: // Get the latest version of the value const Value& getValue(const std::string& name) const; - Value moveValue(const std::string& name); - const Result& getResult(const std::string& name) const; size_t numVersions(const std::string& name) const; @@ -64,6 +64,9 @@ public: } private: + friend class QueryInstance; + Value moveValue(const std::string& name); + // name -> Value with multiple versions std::unordered_map<std::string, std::vector<Result>> valueMap_; }; diff --git a/src/context/Result.h b/src/context/Result.h index 0b116b26afc2441ba5d54841c031a053f82f7b74..01ccbb0bffdb560c99e3a97d60123394520ea5d4 100644 --- a/src/context/Result.h +++ b/src/context/Result.h @@ -15,6 +15,7 @@ namespace nebula { namespace graph { +class ExecutionContext; class ResultBuilder; // An executor will produce a result. @@ -37,10 +38,6 @@ public: return *core_.value; } - Value&& moveValue() { - return std::move(*core_.value); - } - State state() const { return core_.state; } @@ -51,6 +48,11 @@ public: private: friend class ResultBuilder; + friend class ExecutionContext; + + Value&& moveValue() { + return std::move(*core_.value); + } struct Core { State state; diff --git a/src/daemons/CMakeLists.txt b/src/daemons/CMakeLists.txt index 58429a918aba85b274a8ae1c2ec39368713b041b..c73bb9792f8c072ed21476241771d1fd895cfd60 100644 --- a/src/daemons/CMakeLists.txt +++ b/src/daemons/CMakeLists.txt @@ -18,7 +18,7 @@ nebula_add_executable( $<TARGET_OBJECTS:validator_obj> $<TARGET_OBJECTS:planner_obj> $<TARGET_OBJECTS:exec_obj> - $<TARGET_OBJECTS:schedule_obj> + $<TARGET_OBJECTS:scheduler_obj> $<TARGET_OBJECTS:idgenerator_obj> $<TARGET_OBJECTS:context_obj> $<TARGET_OBJECTS:graph_flags_obj> diff --git a/src/exec/Executor.cpp b/src/exec/Executor.cpp index 3cc6f548fa9c76452247a5a19e0f514742a76b24..50f08702e4105ba2d57c4cbe82a73ba6decd5b60 100644 --- a/src/exec/Executor.cpp +++ b/src/exec/Executor.cpp @@ -390,11 +390,6 @@ folly::Future<Status> Executor::error(Status status) const { return folly::makeFuture<Status>(ExecutionError(std::move(status))).via(runner()); } -Status Executor::finish(nebula::Value &&value) { - ectx_->setValue(node()->varName(), std::move(value)); - return Status::OK(); -} - Status Executor::finish(Result &&result) { ectx_->setResult(node()->varName(), std::move(result)); return Status::OK(); diff --git a/src/exec/Executor.h b/src/exec/Executor.h index 60620518cf6a31d141a78460904ce0ffd65aa23a..b93ecccfe6487eb1d3553d7b5ef899c87669070c 100644 --- a/src/exec/Executor.h +++ b/src/exec/Executor.h @@ -91,7 +91,6 @@ protected: folly::Executor *runner() const; // Store the result of this executor to execution context - Status finish(nebula::Value &&value); Status finish(Result &&result); // Dump some execution logging messages, only for debugging diff --git a/src/exec/admin/SnapshotExecutor.cpp b/src/exec/admin/SnapshotExecutor.cpp index 0f9ffa7d56eddfc9079d3cfa5378c3880ac62d38..d9bd64af722cea8df0314fda527d933537bdabb5 100644 --- a/src/exec/admin/SnapshotExecutor.cpp +++ b/src/exec/admin/SnapshotExecutor.cpp @@ -62,8 +62,10 @@ folly::Future<Status> ShowSnapshotsExecutor::execute() { row.values.emplace_back(snapshot.hosts); dataSet.rows.emplace_back(std::move(row)); } - finish(std::move(dataSet)); - return Status::OK(); + return finish(ResultBuilder() + .value(Value(std::move(dataSet))) + .iter(Iterator::Kind::kDefault) + .finish()); }); } } // namespace graph diff --git a/src/exec/admin/SpaceExecutor.cpp b/src/exec/admin/SpaceExecutor.cpp index e24ca8b34f26866e40b99f4d12b86723073b0723..da69c5c7961a9d2fb6d434225902fc13bc5c823e 100644 --- a/src/exec/admin/SpaceExecutor.cpp +++ b/src/exec/admin/SpaceExecutor.cpp @@ -56,8 +56,10 @@ folly::Future<Status> DescSpaceExecutor::execute() { row.values.emplace_back(properties.get_charset_name()); row.values.emplace_back(properties.get_collate_name()); dataSet.rows.emplace_back(std::move(row)); - finish(Value(std::move(dataSet))); - return Status::OK(); + return finish(ResultBuilder() + .value(Value(std::move(dataSet))) + .iter(Iterator::Kind::kDefault) + .finish()); }); } @@ -80,28 +82,29 @@ folly::Future<Status> DropSpaceExecutor::execute() { folly::Future<Status> ShowSpacesExecutor::execute() { dumpLog(); - return qctx()->getMetaClient()->listSpaces() - .via(runner()) - .then([this](StatusOr<std::vector<meta::SpaceIdName>> resp) { - if (!resp.ok()) { - LOG(ERROR) << resp.status(); - return resp.status(); - } - auto spaceItems = std::move(resp).value(); + return qctx()->getMetaClient()->listSpaces().via(runner()).then( + [this](StatusOr<std::vector<meta::SpaceIdName>> resp) { + if (!resp.ok()) { + LOG(ERROR) << resp.status(); + return resp.status(); + } + auto spaceItems = std::move(resp).value(); - DataSet dataSet({"Name"}); - std::set<std::string> orderSpaceNames; - for (auto &space : spaceItems) { - orderSpaceNames.emplace(space.second); - } - for (auto &name : orderSpaceNames) { - Row row; - row.values.emplace_back(name); - dataSet.rows.emplace_back(std::move(row)); - } - finish(std::move(dataSet)); - return Status::OK(); - }); + DataSet dataSet({"Name"}); + std::set<std::string> orderSpaceNames; + for (auto &space : spaceItems) { + orderSpaceNames.emplace(space.second); + } + for (auto &name : orderSpaceNames) { + Row row; + row.values.emplace_back(name); + dataSet.rows.emplace_back(std::move(row)); + } + return finish(ResultBuilder() + .value(Value(std::move(dataSet))) + .iter(Iterator::Kind::kDefault) + .finish()); + }); } folly::Future<Status> ShowCreateSpaceExecutor::execute() { @@ -130,8 +133,10 @@ folly::Future<Status> ShowCreateSpaceExecutor::execute() { properties.get_charset_name().c_str(), properties.get_collate_name().c_str())); dataSet.rows.emplace_back(std::move(row)); - finish(std::move(dataSet)); - return Status::OK(); + return finish(ResultBuilder() + .value(Value(std::move(dataSet))) + .iter(Iterator::Kind::kDefault) + .finish()); }); } } // namespace graph diff --git a/src/exec/logic/LoopExecutor.cpp b/src/exec/logic/LoopExecutor.cpp index 04b596dcd16dd0da7bc851bfc89ffc40764a05f7..6285b7459f8c687da7d5218f6e5786085453232d 100644 --- a/src/exec/logic/LoopExecutor.cpp +++ b/src/exec/logic/LoopExecutor.cpp @@ -9,15 +9,15 @@ #include <folly/String.h> #include "common/interface/gen-cpp2/common_types.h" -#include "planner/Query.h" #include "context/ExpressionContextImpl.h" +#include "planner/Query.h" using folly::stringPrintf; namespace nebula { namespace graph { -LoopExecutor::LoopExecutor(const PlanNode *node, QueryContext* qctx, Executor *body) +LoopExecutor::LoopExecutor(const PlanNode *node, QueryContext *qctx, Executor *body) : Executor("LoopExecutor", node, qctx), body_(DCHECK_NOTNULL(body)) {} folly::Future<Status> LoopExecutor::execute() { @@ -27,8 +27,7 @@ folly::Future<Status> LoopExecutor::execute() { ExpressionContextImpl ctx(ectx_, nullptr); auto value = expr->eval(ctx); DCHECK(value.isBool()); - finish(std::move(value)); - return Status::OK(); + return finish(ResultBuilder().value(std::move(value)).iter(Iterator::Kind::kDefault).finish()); } } // namespace graph diff --git a/src/exec/logic/SelectExecutor.cpp b/src/exec/logic/SelectExecutor.cpp index 4c2560871834cf5ac19a7e1dda5eca5d99387daf..0eea109a8965aa5a3c6333bf9ff95a6df28b9e34 100644 --- a/src/exec/logic/SelectExecutor.cpp +++ b/src/exec/logic/SelectExecutor.cpp @@ -6,8 +6,8 @@ #include "exec/logic/SelectExecutor.h" -#include "planner/Query.h" #include "context/ExpressionContextImpl.h" +#include "planner/Query.h" namespace nebula { namespace graph { @@ -28,8 +28,7 @@ folly::Future<Status> SelectExecutor::execute() { ExpressionContextImpl ctx(ectx_, nullptr); auto value = expr->eval(ctx); DCHECK(value.isBool()); - finish(std::move(value)); - return Status::OK(); + return finish(ResultBuilder().value(std::move(value)).iter(Iterator::Kind::kDefault).finish()); } } // namespace graph diff --git a/src/exec/logic/test/CMakeLists.txt b/src/exec/logic/test/CMakeLists.txt index 20cd38fedc16c2a5fe45cd20f7f1a8f932e35e5f..8aa40b84e81f076d196d1fe24e61d409d49917bc 100644 --- a/src/exec/logic/test/CMakeLists.txt +++ b/src/exec/logic/test/CMakeLists.txt @@ -35,7 +35,7 @@ SET(EXEC_LOGIC_TEST_LIBS $<TARGET_OBJECTS:validator_obj> $<TARGET_OBJECTS:planner_obj> $<TARGET_OBJECTS:exec_obj> - $<TARGET_OBJECTS:schedule_obj> + $<TARGET_OBJECTS:scheduler_obj> $<TARGET_OBJECTS:util_obj> $<TARGET_OBJECTS:idgenerator_obj> $<TARGET_OBJECTS:context_obj> diff --git a/src/exec/maintain/EdgeExecutor.cpp b/src/exec/maintain/EdgeExecutor.cpp index e3b32912ac4fd2776c2c20b698f4b9aaace01ff2..aadef0a145a937665fbe41b2c8510f232b7d322b 100644 --- a/src/exec/maintain/EdgeExecutor.cpp +++ b/src/exec/maintain/EdgeExecutor.cpp @@ -47,8 +47,10 @@ folly::Future<Status> DescEdgeExecutor::execute() { LOG(ERROR) << ret.status(); return ret.status(); } - finish(Value(std::move(ret).value())); - return Status::OK(); + return finish(ResultBuilder() + .value(Value(std::move(ret).value())) + .iter(Iterator::Kind::kDefault) + .finish()); }); } @@ -75,29 +77,30 @@ folly::Future<Status> ShowEdgesExecutor::execute() { dumpLog(); auto spaceId = qctx()->rctx()->session()->space(); - return qctx()->getMetaClient()->listEdgeSchemas(spaceId) - .via(runner()) - .then([this](StatusOr<std::vector<meta::cpp2::EdgeItem>> resp) { - if (!resp.ok()) { - LOG(ERROR) << resp.status(); - return resp.status(); - } - auto edgeItems = std::move(resp).value(); - - DataSet dataSet; - dataSet.colNames = {"Name"}; - std::set<std::string> orderEdgeNames; - for (auto &edge : edgeItems) { - orderEdgeNames.emplace(edge.get_edge_name()); - } - for (auto &name : orderEdgeNames) { - Row row; - row.values.emplace_back(name); - dataSet.rows.emplace_back(std::move(row)); - } - finish(dataSet); - return Status::OK(); - }); + return qctx()->getMetaClient()->listEdgeSchemas(spaceId).via(runner()).then( + [this](StatusOr<std::vector<meta::cpp2::EdgeItem>> resp) { + if (!resp.ok()) { + LOG(ERROR) << resp.status(); + return resp.status(); + } + auto edgeItems = std::move(resp).value(); + + DataSet dataSet; + dataSet.colNames = {"Name"}; + std::set<std::string> orderEdgeNames; + for (auto &edge : edgeItems) { + orderEdgeNames.emplace(edge.get_edge_name()); + } + for (auto &name : orderEdgeNames) { + Row row; + row.values.emplace_back(name); + dataSet.rows.emplace_back(std::move(row)); + } + return finish(ResultBuilder() + .value(Value(std::move(dataSet))) + .iter(Iterator::Kind::kDefault) + .finish()); + }); } folly::Future<Status> ShowCreateEdgeExecutor::execute() { @@ -105,21 +108,25 @@ folly::Future<Status> ShowCreateEdgeExecutor::execute() { auto *sceNode = asNode<ShowCreateEdge>(node()); auto spaceId = qctx()->rctx()->session()->space(); - return qctx()->getMetaClient()->getEdgeSchema(spaceId, sceNode->getName()) - .via(runner()) - .then([this, sceNode](StatusOr<meta::cpp2::Schema> resp) { - if (!resp.ok()) { - LOG(ERROR) << resp.status(); - return resp.status(); - } - auto ret = SchemaUtil::toShowCreateSchema(false, sceNode->getName(), resp.value()); - if (!ret.ok()) { - LOG(ERROR) << ret.status(); - return ret.status(); - } - finish(Value(std::move(ret).value())); - return Status::OK(); - }); + return qctx() + ->getMetaClient() + ->getEdgeSchema(spaceId, sceNode->getName()) + .via(runner()) + .then([this, sceNode](StatusOr<meta::cpp2::Schema> resp) { + if (!resp.ok()) { + LOG(ERROR) << resp.status(); + return resp.status(); + } + auto ret = SchemaUtil::toShowCreateSchema(false, sceNode->getName(), resp.value()); + if (!ret.ok()) { + LOG(ERROR) << ret.status(); + return ret.status(); + } + return finish(ResultBuilder() + .value(std::move(ret).value()) + .iter(Iterator::Kind::kDefault) + .finish()); + }); } folly::Future<Status> AlterEdgeExecutor::execute() { @@ -131,12 +138,13 @@ folly::Future<Status> AlterEdgeExecutor::execute() { aeNode->getSchemaItems(), aeNode->getSchemaProp()) .via(runner()) - .then([](StatusOr<EdgeType> resp) { + .then([this](StatusOr<EdgeType> resp) { if (!resp.ok()) { LOG(ERROR) << resp.status(); return resp.status(); } - return Status::OK(); + return finish( + ResultBuilder().value(Value()).iter(Iterator::Kind::kDefault).finish()); }); } } // namespace graph diff --git a/src/exec/maintain/TagExecutor.cpp b/src/exec/maintain/TagExecutor.cpp index 361a2291ea3e20037d77caad72116c994207d375..f481e6bdd2c21ec93f4f4dd51d49ba951334e978 100644 --- a/src/exec/maintain/TagExecutor.cpp +++ b/src/exec/maintain/TagExecutor.cpp @@ -34,21 +34,25 @@ folly::Future<Status> DescTagExecutor::execute() { auto *dtNode = asNode<DescTag>(node()); auto spaceId = qctx()->rctx()->session()->space(); - return qctx()->getMetaClient()->getTagSchema(spaceId, dtNode->getName()) - .via(runner()) - .then([this](StatusOr<meta::cpp2::Schema> resp) { - if (!resp.ok()) { - LOG(ERROR) << resp.status(); - return resp.status(); - } - auto ret = SchemaUtil::toDescSchema(resp.value()); - if (!ret.ok()) { - LOG(ERROR) << ret.status(); - return ret.status(); - } - finish(Value(std::move(ret).value())); - return Status::OK(); - }); + return qctx() + ->getMetaClient() + ->getTagSchema(spaceId, dtNode->getName()) + .via(runner()) + .then([this](StatusOr<meta::cpp2::Schema> resp) { + if (!resp.ok()) { + LOG(ERROR) << resp.status(); + return resp.status(); + } + auto ret = SchemaUtil::toDescSchema(resp.value()); + if (!ret.ok()) { + LOG(ERROR) << ret.status(); + return ret.status(); + } + return finish(ResultBuilder() + .value(std::move(ret).value()) + .iter(Iterator::Kind::kDefault) + .finish()); + }); } folly::Future<Status> DropTagExecutor::execute() { @@ -73,29 +77,30 @@ folly::Future<Status> ShowTagsExecutor::execute() { dumpLog(); auto spaceId = qctx()->rctx()->session()->space(); - return qctx()->getMetaClient()->listTagSchemas(spaceId) - .via(runner()) - .then([this](StatusOr<std::vector<meta::cpp2::TagItem>> resp) { - if (!resp.ok()) { - LOG(ERROR) << resp.status(); - return resp.status(); - } - auto tagItems = std::move(resp).value(); + return qctx()->getMetaClient()->listTagSchemas(spaceId).via(runner()).then( + [this](StatusOr<std::vector<meta::cpp2::TagItem>> resp) { + if (!resp.ok()) { + LOG(ERROR) << resp.status(); + return resp.status(); + } + auto tagItems = std::move(resp).value(); - DataSet dataSet; - dataSet.colNames = {"Name"}; - std::set<std::string> orderTagNames; - for (auto &tag : tagItems) { - orderTagNames.emplace(tag.get_tag_name()); - } - for (auto &name : orderTagNames) { - Row row; - row.values.emplace_back(name); - dataSet.rows.emplace_back(std::move(row)); - } - finish(dataSet); - return Status::OK(); - }); + DataSet dataSet; + dataSet.colNames = {"Name"}; + std::set<std::string> orderTagNames; + for (auto &tag : tagItems) { + orderTagNames.emplace(tag.get_tag_name()); + } + for (auto &name : orderTagNames) { + Row row; + row.values.emplace_back(name); + dataSet.rows.emplace_back(std::move(row)); + } + return finish(ResultBuilder() + .value(Value(std::move(dataSet))) + .iter(Iterator::Kind::kDefault) + .finish()); + }); } folly::Future<Status> ShowCreateTagExecutor::execute() { @@ -115,8 +120,10 @@ folly::Future<Status> ShowCreateTagExecutor::execute() { LOG(ERROR) << ret.status(); return ret.status(); } - finish(Value(std::move(ret).value())); - return Status::OK(); + return finish(ResultBuilder() + .value(std::move(ret).value()) + .iter(Iterator::Kind::kDefault) + .finish()); }); } diff --git a/src/exec/mutate/InsertEdgesExecutor.cpp b/src/exec/mutate/InsertEdgesExecutor.cpp index bff6dd2d890c195ff056a80522b8d90ee1df1135..3f821c9f5622da8dd5a7a025be069106e7c51e5f 100644 --- a/src/exec/mutate/InsertEdgesExecutor.cpp +++ b/src/exec/mutate/InsertEdgesExecutor.cpp @@ -37,8 +37,7 @@ folly::Future<Status> InsertEdgesExecutor::insertEdges() { return Status::Error("Insert edges not complete, completeness: %d", completeness); } - finish(Value()); - return Status::OK(); + return finish(ResultBuilder().value(Value()).iter(Iterator::Kind::kDefault).finish()); }); } diff --git a/src/exec/mutate/InsertVerticesExecutor.cpp b/src/exec/mutate/InsertVerticesExecutor.cpp index 27231f74df136b0baf130cdf7dbbaac2c1fefbf3..5752db9cb8e767feb67237d4803b6a47684993f2 100644 --- a/src/exec/mutate/InsertVerticesExecutor.cpp +++ b/src/exec/mutate/InsertVerticesExecutor.cpp @@ -22,8 +22,12 @@ folly::Future<Status> InsertVerticesExecutor::insertVertices() { dumpLog(); auto *ivNode = asNode<InsertVertices>(node()); - return qctx()->getStorageClient()->addVertices(ivNode->getSpace(), - ivNode->getVertices(), ivNode->getPropNames(), ivNode->getOverwritable()) + return qctx() + ->getStorageClient() + ->addVertices(ivNode->getSpace(), + ivNode->getVertices(), + ivNode->getPropNames(), + ivNode->getOverwritable()) .via(runner()) .then([this](storage::StorageRpcResponse<storage::cpp2::ExecResponse> resp) { auto completeness = resp.completeness(); @@ -37,8 +41,7 @@ folly::Future<Status> InsertVerticesExecutor::insertVertices() { return Status::Error("Insert vertices not complete, completeness: %d", completeness); } - finish(Value()); - return Status::OK(); + return finish(ResultBuilder().value(Value()).iter(Iterator::Kind::kDefault).finish()); }); } } // namespace graph diff --git a/src/exec/query/test/CMakeLists.txt b/src/exec/query/test/CMakeLists.txt index 643ff49cd012eba1a9375ca3a7c6f616375388a2..4fdf866fe870eb9173a2b807977835eea842d364 100644 --- a/src/exec/query/test/CMakeLists.txt +++ b/src/exec/query/test/CMakeLists.txt @@ -34,7 +34,7 @@ SET(EXEC_QUERY_TEST_OBJS $<TARGET_OBJECTS:parser_obj> $<TARGET_OBJECTS:validator_obj> $<TARGET_OBJECTS:planner_obj> - $<TARGET_OBJECTS:schedule_obj> + $<TARGET_OBJECTS:scheduler_obj> $<TARGET_OBJECTS:exec_obj> $<TARGET_OBJECTS:util_obj> $<TARGET_OBJECTS:idgenerator_obj> @@ -71,4 +71,3 @@ nebula_add_test( LIBRARIES ${EXEC_QUERY_TEST_LIBS} ) - diff --git a/src/mock/test/CMakeLists.txt b/src/mock/test/CMakeLists.txt index 354b2f34346eec0058459d228dd14a691f61683e..35568241774146f5a9c5aeedb6eaa8ca78a1f3d3 100644 --- a/src/mock/test/CMakeLists.txt +++ b/src/mock/test/CMakeLists.txt @@ -15,7 +15,7 @@ set(GRAPH_TEST_LIB $<TARGET_OBJECTS:validator_obj> $<TARGET_OBJECTS:planner_obj> $<TARGET_OBJECTS:exec_obj> - $<TARGET_OBJECTS:schedule_obj> + $<TARGET_OBJECTS:scheduler_obj> $<TARGET_OBJECTS:idgenerator_obj> $<TARGET_OBJECTS:context_obj> $<TARGET_OBJECTS:graph_auth_obj> diff --git a/src/planner/ExecutionPlan.cpp b/src/planner/ExecutionPlan.cpp index ee8da44ed9d0ad2d611400d371e4e2a5e33c2969..837e79c65d5a836319f3758f89758aa923386942 100644 --- a/src/planner/ExecutionPlan.cpp +++ b/src/planner/ExecutionPlan.cpp @@ -8,7 +8,7 @@ #include "exec/Executor.h" #include "util/IdGenerator.h" #include "planner/PlanNode.h" -#include "schedule/Scheduler.h" +#include "scheduler/Scheduler.h" #include "util/ObjectPool.h" namespace nebula { diff --git a/src/planner/test/CMakeLists.txt b/src/planner/test/CMakeLists.txt index c977e3b599b43ff10b4241a7dd1546ffaad222e8..c640cd58cb6ba1bb2d6f674ec6cf390b84441f5d 100644 --- a/src/planner/test/CMakeLists.txt +++ b/src/planner/test/CMakeLists.txt @@ -42,7 +42,7 @@ nebula_add_test( $<TARGET_OBJECTS:validator_obj> $<TARGET_OBJECTS:planner_obj> $<TARGET_OBJECTS:exec_obj> - $<TARGET_OBJECTS:schedule_obj> + $<TARGET_OBJECTS:scheduler_obj> $<TARGET_OBJECTS:util_obj> $<TARGET_OBJECTS:idgenerator_obj> $<TARGET_OBJECTS:context_obj> diff --git a/src/planner/test/ExecutionPlanTest.cpp b/src/planner/test/ExecutionPlanTest.cpp index 9d7c30caf6d589e055ff8ef59b9a1988700136e0..a9f27fd2e9296c7f56a97f6a3c43d11751628ab9 100644 --- a/src/planner/test/ExecutionPlanTest.cpp +++ b/src/planner/test/ExecutionPlanTest.cpp @@ -14,7 +14,7 @@ #include "exec/ExecutionError.h" #include "exec/Executor.h" #include "planner/Query.h" -#include "schedule/Scheduler.h" +#include "scheduler/Scheduler.h" using std::chrono::duration_cast; using std::chrono::microseconds; diff --git a/src/schedule/CMakeLists.txt b/src/scheduler/CMakeLists.txt similarity index 93% rename from src/schedule/CMakeLists.txt rename to src/scheduler/CMakeLists.txt index 85eac880a8444a23f9b527a889f8b35132790f43..989687488e5a671ef38f8568f58149d56a719ab2 100644 --- a/src/schedule/CMakeLists.txt +++ b/src/scheduler/CMakeLists.txt @@ -4,7 +4,7 @@ # attached with Common Clause Condition 1.0, found in the LICENSES directory. nebula_add_library( - schedule_obj + scheduler_obj OBJECT Scheduler.cpp ) diff --git a/src/schedule/Scheduler.cpp b/src/scheduler/Scheduler.cpp similarity index 99% rename from src/schedule/Scheduler.cpp rename to src/scheduler/Scheduler.cpp index 46efe5b6d36d9cb4515771bda74f6aef8eefb615..9e4a4686876735905ac4d6a9fa00e8e4f3e57e47 100644 --- a/src/schedule/Scheduler.cpp +++ b/src/scheduler/Scheduler.cpp @@ -4,7 +4,7 @@ * attached with Common Clause Condition 1.0, found in the LICENSES directory. */ -#include "schedule/Scheduler.h" +#include "scheduler/Scheduler.h" #include "context/QueryContext.h" #include "exec/ExecutionError.h" diff --git a/src/schedule/Scheduler.h b/src/scheduler/Scheduler.h similarity index 96% rename from src/schedule/Scheduler.h rename to src/scheduler/Scheduler.h index 1963a07cc8b2649afa7d9e0dc144f43a35c8e4de..79319a7e1718edf86099bd75a9ede09cc4a5ae77 100644 --- a/src/schedule/Scheduler.h +++ b/src/scheduler/Scheduler.h @@ -4,8 +4,8 @@ * attached with Common Clause Condition 1.0, found in the LICENSES directory. */ -#ifndef SCHEDULE_SCHEDULER_H_ -#define SCHEDULE_SCHEDULER_H_ +#ifndef SCHEDULER_SCHEDULER_H_ +#define SCHEDULER_SCHEDULER_H_ #include <memory> #include <set> @@ -87,4 +87,4 @@ private: } // namespace graph } // namespace nebula -#endif // SCHEDULE_SCHEDULER_H_ +#endif // SCHEDULER_SCHEDULER_H_ diff --git a/src/service/QueryInstance.cpp b/src/service/QueryInstance.cpp index b52f7a32e052f85f6d4d4352c22288dfcf782d55..94caa496ad8f2a69e2a597d3741bf5ab14ef4310 100644 --- a/src/service/QueryInstance.cpp +++ b/src/service/QueryInstance.cpp @@ -12,7 +12,7 @@ #include "exec/Executor.h" #include "planner/ExecutionPlan.h" #include "planner/PlanNode.h" -#include "schedule/Scheduler.h" +#include "scheduler/Scheduler.h" namespace nebula { namespace graph { diff --git a/src/service/QueryInstance.h b/src/service/QueryInstance.h index fd0312b5b6e81b7c2fc5d04dc6f869cbdc8ec6ee..376902024a1bdfbb5b1a23ca70708a957a39960c 100644 --- a/src/service/QueryInstance.h +++ b/src/service/QueryInstance.h @@ -13,7 +13,7 @@ #include "parser/GQLParser.h" #include "validator/ASTValidator.h" #include "context/QueryContext.h" -#include "schedule/Scheduler.h" +#include "scheduler/Scheduler.h" /** * QueryInstance coordinates the execution process,