Skip to content

Commit

Permalink
fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Feb 15, 2022
1 parent f5412d3 commit c89527d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
33 changes: 26 additions & 7 deletions src/graph/executor/algo/SubgraphExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ folly::Future<Status> SubgraphExecutor::execute() {

VLOG(1) << "input: " << subgraph->inputVar() << " output: " << node()->outputVar();
auto iter = ectx_->getResult(subgraph->inputVar()).iter();
std::unordered_set<Value> currentVids;
std::unordered_map<Value, int64_t> currentVids;
currentVids.reserve(iter->size());
historyVids_.reserve(historyVids_.size() + iter->size());
if (currentStep == 1) {
for (; iter->valid(); iter->next()) {
const auto& src = iter->getColumn(nebula::kVid);
currentVids.emplace(src);
currentVids.emplace(src, 0);
}
iter->reset();
}
Expand All @@ -46,15 +46,24 @@ folly::Future<Status> SubgraphExecutor::execute() {
if (biDirectEdgeTypes.empty()) {
iter->next();
} else {
const auto& type = iter->getEdgeProp("*", nebula::kType);
if (type.isInt() && biDirectEdgeTypes.find(type.getInt()) != biDirectEdgeTypes.end()) {
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 || historyVids_[dst] + 2 == currentStep) {
iter->erase();
} else {
iter->next();
}
} else {
iter->next();
}
}
} else {
if (currentVids.emplace(dst).second) {
if (currentVids.emplace(dst, currentStep).second) {
Row row;
row.values.emplace_back(std::move(dst));
ds.rows.emplace_back(std::move(row));
Expand All @@ -72,6 +81,7 @@ folly::Future<Status> SubgraphExecutor::execute() {

void SubgraphExecutor::oneMoreStep() {
auto* subgraph = asNode<Subgraph>(node());
auto currentStep = subgraph->steps();
auto output = subgraph->oneMoreStepOutput();
VLOG(1) << "OneMoreStep Input: " << subgraph->inputVar() << " Output: " << output;
auto iter = ectx_->getResult(subgraph->inputVar()).iter();
Expand All @@ -86,9 +96,18 @@ void SubgraphExecutor::oneMoreStep() {
if (biDirectEdgeTypes.empty()) {
iter->next();
} else {
const auto& type = iter->getEdgeProp("*", nebula::kType);
if (type.isInt() && biDirectEdgeTypes.find(type.getInt()) != biDirectEdgeTypes.end()) {
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 || historyVids_[dst] + 2 == currentStep) {
iter->erase();
} else {
iter->next();
}
} else {
iter->next();
}
Expand Down
2 changes: 1 addition & 1 deletion src/graph/executor/algo/SubgraphExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SubgraphExecutor : public Executor {
void oneMoreStep();

private:
std::unordered_set<Value> historyVids_;
std::unordered_map<Value, int64_t> historyVids_;
};

} // namespace graph
Expand Down

0 comments on commit c89527d

Please sign in to comment.