Skip to content

Commit

Permalink
add markDeleted interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jievince committed Feb 10, 2022
1 parent aa92ed0 commit f8753bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
10 changes: 0 additions & 10 deletions src/graph/optimizer/Optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ StatusOr<const PlanNode *> Optimizer::findBestPlan(QueryContext *qctx) {
auto root = qctx->plan()->root();
auto spaceID = qctx->rctx()->session()->space().id;

// auto status = preprocess(root, qctx, spaceID);
// if (!status.ok()) {
// LOG(ERROR) << "Failed to preprocess plan: " << status;
// }

auto ret = prepare(optCtx.get(), root);
NG_RETURN_IF_ERROR(ret);
auto rootGroup = std::move(ret).value();
Expand All @@ -54,11 +49,6 @@ StatusOr<const PlanNode *> Optimizer::findBestPlan(QueryContext *qctx) {
return newRoot;
}

// Status Optimizer::preprocess(PlanNode *root, graph::QueryContext *qctx, GraphSpaceID spaceID) {
// ColumnTracker colsUsed;
// return root->pruneCulumns(colsUsed, qctx, spaceID);
// }

Status Optimizer::postprocess(PlanNode *root, graph::QueryContext *qctx, GraphSpaceID spaceID) {
if (FLAGS_enable_optimizer_property_pruner_rule) {
graph::PropertyTracker propsUsed;
Expand Down
5 changes: 5 additions & 0 deletions src/graph/planner/plan/PlanNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ class PlanNode {

virtual void accept(PlanNodeVisitor* visitor);

void markDeleted() {
deleted_ = true;
}

virtual PlanNode* clone() const = 0;

virtual void calcCost();
Expand Down Expand Up @@ -315,6 +319,7 @@ class PlanNode {
std::vector<const PlanNode*> dependencies_;
std::vector<Variable*> inputVars_;
std::vector<Variable*> outputVars_;
bool deleted_{false};
};

std::ostream& operator<<(std::ostream& os, PlanNode::Kind kind);
Expand Down
12 changes: 7 additions & 5 deletions src/graph/visitor/PrunePropertiesVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ void PrunePropertiesVisitor::visit(Traverse *node) {
status_ = depsPruneProperties(node->dependencies());
}

// AppendVertices should be deleted when no properties it pulls are used by the parent node.
void PrunePropertiesVisitor::visit(AppendVertices *node) {
auto &colNames = node->colNames();
DCHECK(!colNames.empty());
Expand All @@ -215,8 +216,9 @@ void PrunePropertiesVisitor::visit(AppendVertices *node) {
if (it2 != propsUsed_.vertexPropsMap.end()) {
auto &usedVertexProps = it2->second;
if (usedVertexProps.empty()) {
// markAsToBeDeleted();
// return depsPruneProperties(propsUsed_, qctx_, spaceID_);
node->markDeleted();
status_ = depsPruneProperties(node->dependencies());
return;
}
prunedVertexProps->reserve(usedVertexProps.size());
for (auto &vertexProp : *vertexProps) {
Expand All @@ -238,9 +240,9 @@ void PrunePropertiesVisitor::visit(AppendVertices *node) {
}
}
} else {
// AppendVertices should be deleted when no props are used by the parent node
// markAsToBeDeleted();
// It could be done by ColumnPruner
node->markDeleted();
status_ = depsPruneProperties(node->dependencies());
return;
}
node->setVertexProps(std::move(prunedVertexProps));
}
Expand Down

0 comments on commit f8753bf

Please sign in to comment.