Smyatkin-Maxim commented on code in PR #724:
URL: https://github.com/apache/cloudberry/pull/724#discussion_r2010281084
##########
src/backend/executor/nodeHashjoin.c:
##########
@@ -2156,3 +2176,293 @@ ExecHashJoinInitializeWorker(HashJoinState *state,
ExecSetExecProcNode(&state->js.ps, ExecParallelHashJoin);
}
}
+
+/*
+ * Find "inner var = outer var" in hj->hashclauses and create runtime filter
+ * for it.
+ */
+void
+CreateRuntimeFilter(HashJoinState* hjstate)
+{
+ AttrNumber lattno, rattno;
+ Expr *expr;
+ JoinType jointype;
+ HashJoin *hj;
+ HashState *hstate;
+ AttrFilter *attr_filter;
+ ListCell *lc;
+ List *targets;
+
+ /*
+ * A build-side Bloom filter tells us if a row is definitely not in the
build
+ * side. This allows us to early-eliminate rows or early-accept rows
depending
+ * on the type of join.
+ * Left Outer Join and Full Outer Join output all rows, so a build-side
Bloom
+ * filter would only allow us to early-output. Left Antijoin outputs
only if
+ * there is no match, so again early output. We don't implement early
output
+ * for now.
+ * So it's only applicatable for inner, right and semi join.
+ */
+ jointype = hjstate->js.jointype;
+ if (jointype != JOIN_INNER &&
+ jointype != JOIN_RIGHT &&
+ jointype != JOIN_SEMI)
+ return;
+
+ hstate = castNode(HashState, innerPlanState(hjstate));
+ hstate->filters = NIL;
+
+ /*
+ * check and initialize the runtime filter for all hash conds in
+ * hj->hashclauses
+ */
+ hj = castNode(HashJoin, hjstate->js.ps.plan);
+ foreach (lc, hj->hashclauses)
+ {
+ expr = (Expr *)lfirst(lc);
+
+ if (!IsEqualOp(expr))
+ continue;
+
+ lattno = -1;
+ rattno = -1;
+ if (!CheckEqualArgs(expr, &lattno, &rattno))
+ continue;
+
+ if (lattno < 1 || rattno < 1)
+ continue;
+
+ targets = FindTargetNodes(hjstate, lattno, &lattno);
+ if (lattno == -1 || targets == NULL)
+ continue;
+
+ foreach(lc, targets)
Review Comment:
Is having the same listcell variable here intended?
I guess it should be working, but i`m not sure how it gonna behave if at
some point we add a break statement into the inner loop. And I'm not sure if
this code will continue working in future PG releases :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]