diff --git a/src/executor/CMakeLists.txt b/src/executor/CMakeLists.txt index 6304ef9d6dad3fdd1a51d4ee23cfdd2c6ee9e873..7df169c38e53f24847545f8d2e77755eaeed656f 100644 --- a/src/executor/CMakeLists.txt +++ b/src/executor/CMakeLists.txt @@ -42,6 +42,8 @@ add_library( FetchEdgesExecutor.cpp FetchExecutor.cpp SetExecutor.cpp + FindExecutor.cpp + MatchExecutor.cpp ) add_dependencies( graph_obj diff --git a/src/executor/Executor.cpp b/src/executor/Executor.cpp index a30006f24c20458736c34109e9d34f374d249204..683d0633c4d6e7fee8cdd6b5310d0499db0ac38d 100644 --- a/src/executor/Executor.cpp +++ b/src/executor/Executor.cpp @@ -39,6 +39,8 @@ #include "graph/FetchEdgesExecutor.h" #include "graph/ConfigExecutor.h" #include "graph/SetExecutor.h" +#include "graph/FindExecutor.h" +#include "graph/MatchExecutor.h" namespace nebula { namespace graph { @@ -131,6 +133,12 @@ std::unique_ptr<Executor> Executor::makeExecutor(Sentence *sentence) { case Sentence::Kind::kSet: executor = std::make_unique<SetExecutor>(sentence, ectx()); break; + case Sentence::Kind::kMatch: + executor = std::make_unique<MatchExecutor>(sentence, ectx()); + break; + case Sentence::Kind::kFind: + executor = std::make_unique<FindExecutor>(sentence, ectx()); + break; case Sentence::Kind::kUnknown: LOG(FATAL) << "Sentence kind unknown"; break; diff --git a/src/executor/FindExecutor.cpp b/src/executor/FindExecutor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ea4cc86541e158ed005c1f424db2970544adee20 --- /dev/null +++ b/src/executor/FindExecutor.cpp @@ -0,0 +1,24 @@ +/* Copyright (c) 2019 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License, + * attached with Common Clause Condition 1.0, found in the LICENSES directory. + */ + +#include "base/Base.h" +#include "graph/FindExecutor.h" + +namespace nebula { +namespace graph { + +FindExecutor::FindExecutor(Sentence *sentence, ExecutionContext *ectx) + : TraverseExecutor(ectx) { + sentence_ = static_cast<FindSentence*>(sentence); +} + + +Status FindExecutor::prepare() { + return Status::Error("Does not support"); +} + +} // namespace graph +} // namespace nebula diff --git a/src/executor/FindExecutor.h b/src/executor/FindExecutor.h new file mode 100644 index 0000000000000000000000000000000000000000..4064b9b6debe26126f6d4fc8b4b45ffdb08feae3 --- /dev/null +++ b/src/executor/FindExecutor.h @@ -0,0 +1,40 @@ +/* Copyright (c) 2019 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License, + * attached with Common Clause Condition 1.0, found in the LICENSES directory. + */ + +#ifndef GRAPH_FINDEXECUTOR_H_ +#define GRAPH_FINDEXECUTOR_H_ + +#include "base/Base.h" +#include "graph/TraverseExecutor.h" + +namespace nebula { +namespace graph { + +class FindExecutor final : public TraverseExecutor { +public: + FindExecutor(Sentence *sentence, ExecutionContext *ectx); + + const char* name() const override { + return "FindExecutor"; + } + + Status MUST_USE_RESULT prepare() override; + + void feedResult(std::unique_ptr<InterimResult> result) override { + UNUSED(result); + } + + void execute() override {} + +private: + FindSentence *sentence_{nullptr}; +}; + +} // namespace graph +} // namespace nebula + + +#endif // GRAPH_FINDEXECUTOR_H_ diff --git a/src/executor/MatchExecutor.cpp b/src/executor/MatchExecutor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e058f4fb5fc9a7048acc99c7558a1b3095dea7ee --- /dev/null +++ b/src/executor/MatchExecutor.cpp @@ -0,0 +1,24 @@ +/* Copyright (c) 2019 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License, + * attached with Common Clause Condition 1.0, found in the LICENSES directory. + */ + +#include "base/Base.h" +#include "graph/MatchExecutor.h" + +namespace nebula { +namespace graph { + +MatchExecutor::MatchExecutor(Sentence *sentence, ExecutionContext *ectx) + : TraverseExecutor(ectx) { + sentence_ = static_cast<MatchSentence*>(sentence); +} + + +Status MatchExecutor::prepare() { + return Status::Error("Does not support"); +} + +} // namespace graph +} // namespace nebula diff --git a/src/executor/MatchExecutor.h b/src/executor/MatchExecutor.h new file mode 100644 index 0000000000000000000000000000000000000000..53d88964b025dbbd1a0350d473dde8d4bb2d654d --- /dev/null +++ b/src/executor/MatchExecutor.h @@ -0,0 +1,40 @@ +/* Copyright (c) 2019 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License, + * attached with Common Clause Condition 1.0, found in the LICENSES directory. + */ + +#ifndef GRAPH_MATCHEXECUTOR_H_ +#define GRAPH_MATCHEXECUTOR_H_ + +#include "base/Base.h" +#include "graph/TraverseExecutor.h" + +namespace nebula { +namespace graph { + +class MatchExecutor final : public TraverseExecutor { +public: + MatchExecutor(Sentence *sentence, ExecutionContext *ectx); + + const char* name() const override { + return "UseExecutor"; + } + + Status MUST_USE_RESULT prepare() override; + + void feedResult(std::unique_ptr<InterimResult> result) override { + UNUSED(result); + } + + void execute() override {} + +private: + MatchSentence *sentence_{nullptr}; +}; + +} // namespace graph +} // namespace nebula + + +#endif // GRAPH_MATCHEXECUTOR_H_ diff --git a/src/executor/TraverseExecutor.cpp b/src/executor/TraverseExecutor.cpp index d9f214f8ad8213a855e65c77f344a5d0b150cb87..7ad71fe2e31aa02fb74cd15915ef88404635b15f 100644 --- a/src/executor/TraverseExecutor.cpp +++ b/src/executor/TraverseExecutor.cpp @@ -15,6 +15,8 @@ #include "dataman/RowReader.h" #include "dataman/RowWriter.h" #include "graph/SetExecutor.h" +#include "graph/FindExecutor.h" +#include "graph/MatchExecutor.h" namespace nebula { namespace graph { @@ -48,6 +50,12 @@ TraverseExecutor::makeTraverseExecutor(Sentence *sentence, ExecutionContext *ect case Sentence::Kind::kSet: executor = std::make_unique<SetExecutor>(sentence, ectx); break; + case Sentence::Kind::kMatch: + executor = std::make_unique<MatchExecutor>(sentence, ectx); + break; + case Sentence::Kind::kFind: + executor = std::make_unique<FindExecutor>(sentence, ectx); + break; case Sentence::Kind::kUnknown: LOG(FATAL) << "Sentence kind unknown"; break; diff --git a/src/executor/test/DataTest.cpp b/src/executor/test/DataTest.cpp index b52c49f147be840d828ec070513b1feb8c2f0235..581a27988f7509476cd7008cac279c7ca759123d 100644 --- a/src/executor/test/DataTest.cpp +++ b/src/executor/test/DataTest.cpp @@ -359,6 +359,23 @@ TEST_F(DataTest, InsertVertex) { // TODO: Test insert multi tags, and delete one of them then check other existent } +TEST_F(DataTest, FindTest) { + { + cpp2::ExecutionResponse resp; + std::string cmd = "FIND name FROM person"; + auto code = client_->execute(cmd, resp); + ASSERT_EQ(cpp2::ErrorCode::E_EXECUTION_ERROR, code); + } +} + +TEST_F(DataTest, MatchTest) { + { + cpp2::ExecutionResponse resp; + std::string cmd = "MATCH"; + auto code = client_->execute(cmd, resp); + ASSERT_EQ(cpp2::ErrorCode::E_EXECUTION_ERROR, code); + } +} + } // namespace graph } // namespace nebula -