-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish the bug in validator with good Executor Framework (#4574)
* Add validator and fix executor * change some small issues
- Loading branch information
1 parent
c594a10
commit 8bac443
Showing
13 changed files
with
148 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright (c) 2020 vesoft inc. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
#include "graph/executor/algo/IsomorExecutor.h" | ||
|
||
#include "graph/planner/plan/Algo.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
folly::Future<Status> IsomorExecutor::execute() { | ||
// TODO: Replace the following codes with subgraph matching. Return type. | ||
SCOPED_TIMER(&execTime_); | ||
auto* subgraph = asNode<Subgraph>(node()); | ||
DataSet ds; | ||
ds.colNames = subgraph->colNames(); | ||
|
||
uint32_t steps = subgraph->steps(); | ||
const auto& currentStepVal = ectx_->getValue(subgraph->currentStepVar()); | ||
DCHECK(currentStepVal.isInt()); | ||
auto currentStep = currentStepVal.getInt(); | ||
auto resultVar = subgraph->resultVar(); | ||
|
||
auto iter = ectx_->getResult(subgraph->inputVar()).iter(); | ||
auto gnSize = iter->size(); | ||
|
||
ResultBuilder builder; | ||
builder.value(iter->valuePtr()); | ||
|
||
std::unordered_map<Value, int64_t> currentVids; | ||
currentVids.reserve(gnSize); | ||
historyVids_.reserve(historyVids_.size() + gnSize); | ||
if (currentStep == 1) { | ||
for (; iter->valid(); iter->next()) { | ||
const auto& src = iter->getColumn(nebula::kVid); | ||
currentVids.emplace(src, 0); | ||
} | ||
iter->reset(); | ||
} | ||
auto& biDirectEdgeTypes = subgraph->biDirectEdgeTypes(); | ||
while (iter->valid()) { | ||
const auto& dst = iter->getEdgeProp("*", nebula::kDst); | ||
auto findIter = historyVids_.find(dst); | ||
if (findIter != historyVids_.end()) { | ||
if (biDirectEdgeTypes.empty()) { | ||
iter->next(); | ||
} else { | ||
const auto& typeVal = iter->getEdgeProp("*", nebula::kType); | ||
if (UNLIKELY(!typeVal.isInt())) { | ||
iter->erase(); | ||
continue; | ||
} | ||
auto type = typeVal.getInt(); | ||
if (biDirectEdgeTypes.find(type) != biDirectEdgeTypes.end()) { | ||
if (type < 0 || findIter->second + 2 == currentStep) { | ||
iter->erase(); | ||
} else { | ||
iter->next(); | ||
} | ||
} else { | ||
iter->next(); | ||
} | ||
} | ||
} else { | ||
if (currentStep == steps) { | ||
iter->erase(); | ||
continue; | ||
} | ||
if (currentVids.emplace(dst, currentStep).second) { | ||
Row row; | ||
row.values.emplace_back(std::move(dst)); | ||
ds.rows.emplace_back(std::move(row)); | ||
} | ||
iter->next(); | ||
} | ||
} | ||
iter->reset(); | ||
builder.iter(std::move(iter)); | ||
ectx_->setResult(resultVar, builder.build()); | ||
// update historyVids | ||
historyVids_.insert(std::make_move_iterator(currentVids.begin()), | ||
std::make_move_iterator(currentVids.end())); | ||
return finish(ResultBuilder().value(Value(std::move(ds))).build()); | ||
} | ||
|
||
} // namespace graph | ||
} // namespace nebula |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2020 vesoft inc. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
#ifndef GRAPH_EXECUTOR_ALGO_ISOMOREXECUTOR_H_ | ||
#define GRAPH_EXECUTOR_ALGO_ISOMOREXECUTOR_H_ | ||
|
||
#include "graph/executor/Executor.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
class IsomorExecutor : public Executor { | ||
public: | ||
IsomorExecutor(const PlanNode* node, QueryContext* qctx) | ||
: Executor("IsomorExecutor", node, qctx) {} | ||
|
||
folly::Future<Status> execute() override; | ||
|
||
private: | ||
std::unordered_map<Value, int64_t> historyVids_; | ||
}; | ||
|
||
} // namespace graph | ||
} // namespace nebula | ||
|
||
#endif // GRAPH_EXECUTOR_ALGO_ISOMOREXECUTOR_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters