Skip to content

Commit

Permalink
Shortest path (#4071)
Browse files Browse the repository at this point in the history
* shortestpath

* frame

* fix

* fix

* fix

* almost finish

* fix

* fix

* add tck

* refactor shortest path

* conjunct path

* conjunct path

* create left & right path

* fix error

* fix compile error

* fix createPath error

* concurrent execute

* rebase

* add shortestpath plan

* fix error

* add test case

* same change

* add comment

* fix spell error

* batch process

* batch shortest path

* add singleShortestPath file

* add batchshortest path

* new batch process

* fix error

* rebase

* format

* fix batchShortestPath 's single problem

* fix define error

* fix test case

* Synchronous interface is replaced by asynchronous interface in batch shortest path

* Synchronous interface is replaced by asynchronous interface in single shortest path

* del testcase

Co-authored-by: jackwener <30525741+jackwener@users.noreply.github.com>
Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 7, 2022
1 parent 591a8c5 commit 56856e7
Show file tree
Hide file tree
Showing 36 changed files with 2,809 additions and 199 deletions.
1 change: 1 addition & 0 deletions src/graph/context/Iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ class SequentialIter : public Iterator {
friend class DataCollectExecutor;
friend class AppendVerticesExecutor;
friend class TraverseExecutor;
friend class ShortestPathExecutor;

void doReset(size_t pos) override;

Expand Down
11 changes: 8 additions & 3 deletions src/graph/context/ast/CypherAstContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ enum class CypherClauseKind : uint8_t {
kOrderBy,
kPagination,
kYield,
kShortestPath,
kAllShortestPaths,
};

enum class PatternKind : uint8_t {
Expand Down Expand Up @@ -80,6 +82,9 @@ struct Path final {
std::vector<std::string> compareVariables;
// "(v)-[:like]->()" in (v)-[:like]->()
std::string collectVariable;

enum PathType : int8_t { kDefault, kAllShortest, kSingleShortest };
PathType pathType{PathType::kDefault};
};

struct CypherClauseContextBase : AstContext {
Expand Down Expand Up @@ -210,8 +215,8 @@ struct NodeContext final : PatternContext {
QueryContext* qctx;
WhereClauseContext* bindWhereClause;
GraphSpaceID spaceId;
NodeInfo* info{nullptr};
std::unordered_set<std::string>* nodeAliasesAvailable;
NodeInfo* info;
std::unordered_set<std::string>* nodeAliasesAvailable{nullptr};

// Output fields
ScanInfo scanInfo;
Expand All @@ -227,7 +232,7 @@ struct EdgeContext final : PatternContext {
QueryContext* qctx;
WhereClauseContext* bindWhereClause;
GraphSpaceID spaceId;
EdgeInfo* info{nullptr};
EdgeInfo* info;

// Output fields
ScanInfo scanInfo;
Expand Down
4 changes: 4 additions & 0 deletions src/graph/executor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ nebula_add_library(
algo/BFSShortestPathExecutor.cpp
algo/MultiShortestPathExecutor.cpp
algo/ProduceAllPathsExecutor.cpp
algo/ShortestPathExecutor.cpp
algo/CartesianProductExecutor.cpp
algo/SubgraphExecutor.cpp
algo/ShortestPathBase.cpp
algo/SingleShortestPath.cpp
algo/BatchShortestPath.cpp
admin/AddHostsExecutor.cpp
admin/DropHostsExecutor.cpp
admin/SwitchSpaceExecutor.cpp
Expand Down
4 changes: 4 additions & 0 deletions src/graph/executor/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "graph/executor/algo/CartesianProductExecutor.h"
#include "graph/executor/algo/MultiShortestPathExecutor.h"
#include "graph/executor/algo/ProduceAllPathsExecutor.h"
#include "graph/executor/algo/ShortestPathExecutor.h"
#include "graph/executor/algo/SubgraphExecutor.h"
#include "graph/executor/logic/ArgumentExecutor.h"
#include "graph/executor/logic/LoopExecutor.h"
Expand Down Expand Up @@ -545,6 +546,9 @@ Executor *Executor::makeExecutor(QueryContext *qctx, const PlanNode *node) {
case PlanNode::Kind::kAlterSpace: {
return pool->add(new AlterSpaceExecutor(node, qctx));
}
case PlanNode::Kind::kShortestPath: {
return pool->add(new ShortestPathExecutor(node, qctx));
}
case PlanNode::Kind::kUnknown: {
LOG(FATAL) << "Unknown plan node kind " << static_cast<int32_t>(node->kind());
break;
Expand Down
Loading

0 comments on commit 56856e7

Please sign in to comment.