Skip to content

Commit

Permalink
remove project
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Feb 16, 2022
1 parent 3b7b193 commit 09ed8b4
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 52 deletions.
1 change: 1 addition & 0 deletions src/graph/context/ast/QueryAstContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ struct SubgraphContext final : public AstContext {
std::vector<std::string> colNames;
std::unordered_set<EdgeType> edgeTypes;
std::unordered_set<EdgeType> biDirectEdgeTypes;
std::vector<Value::Type> colType;
bool withProp{false};
bool getVertexProp{false};
bool getEdgeProp{false};
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 @@ -8,7 +8,7 @@

#include "graph/executor/Executor.h"

// Subgraph receive result from GetNeightbors
// Subgraph receive result from GetNeighbors
// There are two Main functions
// First : Extract the deduplicated destination VID from GetNeighbors
// Second: Delete previously visited edges and save the result(iter) to the variable `resultVar`
Expand Down
40 changes: 24 additions & 16 deletions src/graph/executor/query/DataCollectExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,20 @@ folly::Future<Status> DataCollectExecutor::doCollect() {
}

Status DataCollectExecutor::collectSubgraph(const std::vector<std::string>& vars) {
auto* dc = asNode<DataCollect>(node());
std::pair<bool, bool> outCol = dc->subgraphCol();
const auto* dc = asNode<DataCollect>(node());
const auto& colType = dc->colType();
DataSet ds;
ds.colNames = std::move(colNames_);
for (auto i = vars.begin(); i != vars.end(); ++i) {
const auto& hist = ectx_->getHistory(*i);
for (auto j = hist.begin(); j != hist.end(); ++j) {
auto iter = (*j).iter();
auto* gnIter = static_cast<GetNeighborsIter*>(iter.get());
List vertices;
List edges;
if (outCol.first) {
const auto& hist = ectx_->getHistory(vars[0]);
for (const auto& result : hist) {
auto iter = result.iter();
auto* gnIter = static_cast<GetNeighborsIter*>(iter.get());
List vertices;
List edges;
Row row;
bool notEmpty = false;
for (const auto& type : colType) {
if (type == Value::Type::VERTEX) {
auto originVertices = gnIter->getVertices();
vertices.reserve(originVertices.size());
for (auto& v : originVertices.values) {
Expand All @@ -81,8 +83,11 @@ Status DataCollectExecutor::collectSubgraph(const std::vector<std::string>& vars
}
vertices.emplace_back(std::move(v));
}
}
if (outCol.second) {
if (!vertices.empty()) {
notEmpty = true;
row.emplace_back(std::move(vertices));
}
} else {
auto originEdges = gnIter->getEdges();
edges.reserve(originEdges.size());
for (auto& edge : originEdges.values) {
Expand All @@ -91,11 +96,14 @@ Status DataCollectExecutor::collectSubgraph(const std::vector<std::string>& vars
}
edges.emplace_back(std::move(edge));
}
if (!edges.empty()) {
notEmpty = true;
}
row.emplace_back(std::move(edges));
}
if (vertices.empty() && edges.empty()) {
break;
}
ds.rows.emplace_back(Row({std::move(vertices), std::move(edges)}));
}
if (notEmpty) {
ds.rows.emplace_back(std::move(row));
}
}
result_.setDataSet(std::move(ds));
Expand Down
2 changes: 1 addition & 1 deletion src/graph/planner/ngql/SubgraphPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ StatusOr<SubPlan> SubgraphPlanner::nSteps(SubPlan& startVidPlan, const std::stri
auto* dc = DataCollect::make(qctx, DataCollect::DCKind::kSubgraph);
dc->addDep(loop);
dc->setInputVars({resultVar});
dc->setSubgraphCol(subgraphCtx_->getVertexProp, subgraphCtx_->getEdgeProp);
dc->setColType(std::move(subgraphCtx_->colType));
dc->setColNames(subgraphCtx_->colNames);

SubPlan subPlan;
Expand Down
11 changes: 5 additions & 6 deletions src/graph/planner/plan/Query.h
Original file line number Diff line number Diff line change
Expand Up @@ -1226,13 +1226,12 @@ class DataCollect final : public VariableDependencyNode {
return distinct_;
}

void setSubgraphCol(bool getVertices, bool getEdges) {
subgraphCol_.first = getVertices;
subgraphCol_.second = getEdges;
void setColType(std::vector<Value::Type>&& colType) {
colType_ = std::move(colType);
}

const std::pair<bool, bool>& subgraphCol() {
return subgraphCol_;
const std::vector<Value::Type>& colType() const {
return colType_;
}

PlanNode* clone() const override;
Expand All @@ -1249,7 +1248,7 @@ class DataCollect final : public VariableDependencyNode {
DCKind kind_;
// using for m to n steps
StepClause step_;
std::pair<bool, bool> subgraphCol_;
std::vector<Value::Type> colType_;
bool distinct_{false};
};

Expand Down
5 changes: 4 additions & 1 deletion src/graph/validator/GetSubgraphValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,25 @@ Status GetSubgraphValidator::validateYield(YieldClause* yield) {
}
auto size = yield->columns().size();
outputs_.reserve(size);

std::vector<Value::Type> colType;
for (const auto& col : yield->columns()) {
const std::string& colStr = col->expr()->toString();
if (colStr == "VERTICES") {
subgraphCtx_->getVertexProp = true;
colType.emplace_back(Value::Type::VERTEX);
} else if (colStr == "EDGES") {
if (subgraphCtx_->steps.steps() == 0) {
return Status::SemanticError("Get Subgraph 0 STEPS only support YIELD vertices");
}
subgraphCtx_->getEdgeProp = true;
colType.emplace_back(Value::Type::EDGE);
} else {
return Status::SemanticError("Get Subgraph only support YIELD vertices OR edges");
}
outputs_.emplace_back(col->name(), Value::Type::LIST);
}
subgraphCtx_->colNames = getOutColNames();
subgraphCtx_->colType = std::move(colType);
return Status::OK();
}

Expand Down
1 change: 0 additions & 1 deletion tests/tck/features/subgraph/subgraph.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,6 @@ Feature: Integer Vid subgraph
| relationships |
| <[edge1]> |
| <[edge2]> |
| [] |
When executing query:
"""
GET SUBGRAPH WITH PROP FROM hash('Tony Parker') BOTH like YIELD edges as relationships, vertices as nodes
Expand Down
27 changes: 1 addition & 26 deletions tests/tck/features/subgraph/subgraph.feature
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,6 @@ Feature: subgraph
| b |
| <[edge1]> |
| <[edge2]> |
| [] |
When executing query:
"""
GET SUBGRAPH WITH PROP FROM 'Tony Parker' BOTH like YIELD edges as a, vertices as b
Expand Down Expand Up @@ -1011,31 +1010,7 @@ Feature: subgraph
| <[vertex4]> | <[edge4]> |
| <[vertex5]> | [] |

Scenario: Get subgraph in a space which doesn't have edge schema
Given an empty graph
And create a space with following options:
| partition_num | 9 |
| replica_factor | 1 |
| vid_type | FIXED_STRING(20) |
And having executed:
"""
CREATE TAG IF NOT EXISTS person(name string);
"""
When try to execute query:
"""
INSERT VERTEX person VALUES "Tom":("Tom")
"""
Then the execution should be successful
When executing query:
"""
GET SUBGRAPH 1 STEPS FROM "Tom" YIELD vertices as nodes, edges as relationships
"""
Then the result should be, in any order, with relax comparison:
| nodes | relationships |
| [("Tom")] | [] |
| [] | [] |

Scenario: Get subgraph in a space which doesn't have edge schema
Scenario: Get subgraph in a space which doesn't have edge schema
Given an empty graph
And create a space with following options:
| partition_num | 9 |
Expand Down

0 comments on commit 09ed8b4

Please sign in to comment.