Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support variable when seeking by property index in match clause #5553

Merged
merged 10 commits into from
May 18, 2023
Prev Previous commit
Next Next commit
Rename
  • Loading branch information
yixinglu committed May 16, 2023
commit 0003a13d373cb806a87c76ab3f87ea539a0cfc25
2 changes: 1 addition & 1 deletion src/graph/context/ast/CypherAstContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ struct NodeContext final : PatternContext {
: PatternContext(PatternKind::kNode, q, b, g), info(i) {}

const NodeInfo* info;
std::unordered_set<std::string>* nodeAliasesAvailable{nullptr};
std::unordered_set<std::string>* aliasesAvailable{nullptr};

// Output fields
Set ids;
Expand Down
2 changes: 1 addition & 1 deletion src/graph/planner/match/ArgumentFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace nebula {
namespace graph {
bool ArgumentFinder::matchNode(NodeContext* nodeCtx) {
return nodeCtx->nodeAliasesAvailable->count(nodeCtx->info->alias) > 0;
return nodeCtx->aliasesAvailable->count(nodeCtx->info->alias) > 0;
}

bool ArgumentFinder::matchEdge(EdgeContext* nodeCtx) {
Expand Down
2 changes: 1 addition & 1 deletion src/graph/planner/match/MatchPathPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Status MatchPathPlanner::findStarts(WhereClauseContext* bindWhereClause,
for (auto& finder : startVidFinders) {
for (size_t i = 0; i < nodeInfos.size() && !foundStart; ++i) {
NodeContext nodeCtx(qctx, bindWhereClause, spaceId, &nodeInfos[i]);
nodeCtx.nodeAliasesAvailable = &nodeAliasesSeen;
nodeCtx.aliasesAvailable = &nodeAliasesSeen;
auto nodeFinder = finder();
if (nodeFinder->match(&nodeCtx)) {
auto plan = nodeFinder->transform(&nodeCtx);
Expand Down
2 changes: 1 addition & 1 deletion src/graph/planner/match/ShortestPathPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ StatusOr<SubPlan> ShortestPathPlanner::transform(WhereClauseContext* bindWhereCl
bool foundIndex = false;
for (auto& finder : startVidFinders) {
auto nodeCtx = NodeContext(qctx, bindWhereClause, spaceId, &nodeInfo);
nodeCtx.nodeAliasesAvailable = &nodeAliasesSeen;
nodeCtx.aliasesAvailable = &nodeAliasesSeen;
auto nodeFinder = finder();
if (nodeFinder->match(&nodeCtx)) {
auto status = nodeFinder->transform(&nodeCtx);
Expand Down
5 changes: 2 additions & 3 deletions src/graph/planner/match/VariablePropIndexSeek.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ namespace nebula {
namespace graph {

bool VariablePropIndexSeek::matchNode(NodeContext* nodeCtx) {
auto& nodeInfo = *nodeCtx->info;
const auto& labels = nodeInfo.labels;
const auto& labels = nodeCtx->info->labels;
if (labels.size() != 1) {
// TODO multiple tag index seek need the IndexScan support
VLOG(2) << "Multiple tag index seek is not supported now.";
Expand All @@ -25,7 +24,7 @@ bool VariablePropIndexSeek::matchNode(NodeContext* nodeCtx) {
auto whereClause = nodeCtx->bindWhereClause;
if (!whereClause || !whereClause->filter) return false;

auto qctx = nodeCtx->qctx;
// auto qctx = nodeCtx->qctx;
auto newFilter = ExpressionUtils::rewriteInnerInExpr(whereClause->filter);
auto filter = newFilter;
// auto filter = MatchSolver::rewriteTagIndexFilter(
Expand Down
2 changes: 1 addition & 1 deletion src/graph/planner/match/VariableVertexIdSeek.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bool VariableVertexIdSeek::matchNode(NodeContext *nodeCtx) {
}

// exclude the case where `refVarName` is from the path pattern of current match
if (!nodeCtx->nodeAliasesAvailable->count(refVarName)) {
if (!nodeCtx->aliasesAvailable->count(refVarName)) {
return false;
}

Expand Down
3 changes: 3 additions & 0 deletions src/graph/util/ExpressionUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
DECLARE_int32(max_expression_depth);

namespace nebula {

class ObjectPool;

namespace graph {

class ExpressionUtils {
public:
explicit ExpressionUtils(...) = delete;
Expand Down