Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 56856e7

Browse files
nevermore3jackwenerSophie-Xie
authored
Shortest path (vesoft-inc#4071)
* 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 <[email protected]> Co-authored-by: Sophie <[email protected]>
1 parent 591a8c5 commit 56856e7

36 files changed

+2809
-199
lines changed

src/graph/context/Iterator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ class SequentialIter : public Iterator {
499499
friend class DataCollectExecutor;
500500
friend class AppendVerticesExecutor;
501501
friend class TraverseExecutor;
502+
friend class ShortestPathExecutor;
502503

503504
void doReset(size_t pos) override;
504505

src/graph/context/ast/CypherAstContext.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ enum class CypherClauseKind : uint8_t {
2424
kOrderBy,
2525
kPagination,
2626
kYield,
27+
kShortestPath,
28+
kAllShortestPaths,
2729
};
2830

2931
enum class PatternKind : uint8_t {
@@ -80,6 +82,9 @@ struct Path final {
8082
std::vector<std::string> compareVariables;
8183
// "(v)-[:like]->()" in (v)-[:like]->()
8284
std::string collectVariable;
85+
86+
enum PathType : int8_t { kDefault, kAllShortest, kSingleShortest };
87+
PathType pathType{PathType::kDefault};
8388
};
8489

8590
struct CypherClauseContextBase : AstContext {
@@ -210,8 +215,8 @@ struct NodeContext final : PatternContext {
210215
QueryContext* qctx;
211216
WhereClauseContext* bindWhereClause;
212217
GraphSpaceID spaceId;
213-
NodeInfo* info{nullptr};
214-
std::unordered_set<std::string>* nodeAliasesAvailable;
218+
NodeInfo* info;
219+
std::unordered_set<std::string>* nodeAliasesAvailable{nullptr};
215220

216221
// Output fields
217222
ScanInfo scanInfo;
@@ -227,7 +232,7 @@ struct EdgeContext final : PatternContext {
227232
QueryContext* qctx;
228233
WhereClauseContext* bindWhereClause;
229234
GraphSpaceID spaceId;
230-
EdgeInfo* info{nullptr};
235+
EdgeInfo* info;
231236

232237
// Output fields
233238
ScanInfo scanInfo;

src/graph/executor/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ nebula_add_library(
4343
algo/BFSShortestPathExecutor.cpp
4444
algo/MultiShortestPathExecutor.cpp
4545
algo/ProduceAllPathsExecutor.cpp
46+
algo/ShortestPathExecutor.cpp
4647
algo/CartesianProductExecutor.cpp
4748
algo/SubgraphExecutor.cpp
49+
algo/ShortestPathBase.cpp
50+
algo/SingleShortestPath.cpp
51+
algo/BatchShortestPath.cpp
4852
admin/AddHostsExecutor.cpp
4953
admin/DropHostsExecutor.cpp
5054
admin/SwitchSpaceExecutor.cpp

src/graph/executor/Executor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "graph/executor/algo/CartesianProductExecutor.h"
4949
#include "graph/executor/algo/MultiShortestPathExecutor.h"
5050
#include "graph/executor/algo/ProduceAllPathsExecutor.h"
51+
#include "graph/executor/algo/ShortestPathExecutor.h"
5152
#include "graph/executor/algo/SubgraphExecutor.h"
5253
#include "graph/executor/logic/ArgumentExecutor.h"
5354
#include "graph/executor/logic/LoopExecutor.h"
@@ -545,6 +546,9 @@ Executor *Executor::makeExecutor(QueryContext *qctx, const PlanNode *node) {
545546
case PlanNode::Kind::kAlterSpace: {
546547
return pool->add(new AlterSpaceExecutor(node, qctx));
547548
}
549+
case PlanNode::Kind::kShortestPath: {
550+
return pool->add(new ShortestPathExecutor(node, qctx));
551+
}
548552
case PlanNode::Kind::kUnknown: {
549553
LOG(FATAL) << "Unknown plan node kind " << static_cast<int32_t>(node->kind());
550554
break;

0 commit comments

Comments
 (0)