Skip to content

Commit

Permalink
Fix ExtractFilterExprVisitor.
Browse files Browse the repository at this point in the history
  • Loading branch information
xtcyclist committed Mar 24, 2023
1 parent 2f5a57d commit 1619a8a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/graph/visitor/ExtractFilterExprVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,26 @@ void ExtractFilterExprVisitor::ExtractRemainExpr(LogicalExpression *expr,
extractedExpr_ = operands[0];
}

LogicalExpression *remainedExpr = nullptr;
if (remainedOperands.size() > 1) {
auto remainedExpr = LogicalExpression::makeAnd(pool_);
remainedExpr = LogicalExpression::makeAnd(pool_);
remainedExpr->setOperands(std::move(remainedOperands));
remainedExpr_ = std::move(remainedExpr);
} else {
remainedExpr_ = std::move(remainedOperands[0]);
remainedExpr = static_cast<LogicalExpression *>(std::move(remainedOperands[0]));
}
if (remainedExpr_ != nullptr) {
if (remainedExprFromAnd_) {
auto mergeExpr = LogicalExpression::makeAnd(pool_, remainedExpr_, std::move(remainedExpr));
remainedExpr_ = std::move(mergeExpr);
remainedExprFromAnd_ = true;
} else {
auto mergeExpr = LogicalExpression::makeOr(pool_, remainedExpr_, std::move(remainedExpr));
remainedExpr_ = std::move(mergeExpr);
remainedExprFromAnd_ = true;
}
} else {
remainedExpr_ = std::move(remainedExpr);
remainedExprFromAnd_ = true;
}
}

Expand Down Expand Up @@ -375,6 +389,7 @@ void ExtractFilterExprVisitor::visit(LogicalExpression *expr) {
DCHECK_EQ(expr->kind(), Expression::Kind::kLogicalAnd);
DCHECK_EQ(expr->operands().size(), 2);
remainedExpr_ = expr->operands()[1]->clone();
remainedExprFromAnd_ = false;
expr->operands().pop_back();
}
} else {
Expand Down
1 change: 1 addition & 0 deletions src/graph/visitor/ExtractFilterExprVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class ExtractFilterExprVisitor final : public ExprVisitorImpl {
bool hasSplit{false};
bool splitForbidden{false};
Expression *remainedExpr_{nullptr};
bool remainedExprFromAnd_{false};
Expression *extractedExpr_{nullptr};
PushType pushType_{PushType::kGetNeighbors};
std::vector<std::string> colNames_;
Expand Down

0 comments on commit 1619a8a

Please sign in to comment.