Skip to content

Commit

Permalink
Move the prepare processing of findpath to execute (#2303)
Browse files Browse the repository at this point in the history
* Move prepare handle to execute

* address Shylock-Hg's comment

* modify cppLint
  • Loading branch information
laura-ding committed Aug 26, 2020
1 parent 8390267 commit 87f8b0b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: jitterbit/get-changed-files@v1
id: diff
- name: Cpplint
run: |
ln -snf $PWD/.linters/cpp/hooks/pre-commit.sh $PWD/.linters/cpp/pre-commit.sh
.linters/cpp/pre-commit.sh ${{ steps.diff.outputs.all }}
.linters/cpp/pre-commit.sh $(git --no-pager diff --diff-filter=d --name-only HEAD^ HEAD)
build:
name: build
Expand Down
9 changes: 9 additions & 0 deletions src/graph/FindPathExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ FindPathExecutor::FindPathExecutor(Sentence *sentence, ExecutionContext *exct)
}

Status FindPathExecutor::prepare() {
return Status::OK();
}

Status FindPathExecutor::prepareClauses() {
spaceId_ = ectx()->rctx()->session()->space();
Status status;
expCtx_ = std::make_unique<ExpressionContext>();
Expand Down Expand Up @@ -71,6 +75,11 @@ Status FindPathExecutor::beforeExecute() {
break;;
}

status = prepareClauses();
if (!status.ok()) {
break;
}

status = prepareOver();
if (!status.ok()) {
break;
Expand Down
2 changes: 2 additions & 0 deletions src/graph/FindPathExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class FindPathExecutor final : public TraverseExecutor {
cpp2::RowValue buildPathRow(const Path &path);

private:
Status prepareClauses();

// Do some prepare work that can not do in prepare()
Status beforeExecute();

Expand Down
19 changes: 19 additions & 0 deletions src/graph/test/FindPathTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,25 @@ TEST_F(FindPathTest, UseUUID) {
ASSERT_TRUE(resp.get_rows() != nullptr);
ASSERT_EQ(resp.get_rows()->size(), 1);
}
{
// without use space
auto client = gEnv->getClient();
cpp2::ExecutionResponse resp;
auto query = "FIND SHORTEST PATH FROM UUID(\"Tim Duncan\") TO UUID(\"Tony Parker\") "
"OVER like UPTO 5 STEPS";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::E_EXECUTION_ERROR, code);
ASSERT_EQ("Please choose a graph space with `USE spaceName' firstly",
*(resp.get_error_msg()));

// multi sentences
query = "USE nba; FIND SHORTEST PATH FROM UUID(\"Tim Duncan\") TO UUID(\"Tony Parker\") "
"OVER like UPTO 5 STEPS";
code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code) << *(resp.get_error_msg());
ASSERT_TRUE(resp.get_rows() != nullptr);
ASSERT_EQ(resp.get_rows()->size(), 1);
}
}
} // namespace graph
} // namespace nebula

0 comments on commit 87f8b0b

Please sign in to comment.