Skip to content

Commit

Permalink
Fix with code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyue-hashdata committed Nov 26, 2024
1 parent 86dc41d commit 99eabb2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
7 changes: 5 additions & 2 deletions src/backend/executor/nodeHash.c
Original file line number Diff line number Diff line change
Expand Up @@ -4282,7 +4282,10 @@ ResetRuntimeFilter(HashState *node)

attr_filter->blm_filter = bloom_create_aggresive(node->ps.plan->plan_rows,
work_mem, random());
attr_filter->min = LLONG_MAX;
attr_filter->max = LLONG_MIN;

StaticAssertDecl(sizeof(LONG_MAX) == sizeof(Datum), "sizeof(LONG_MAX) should be equal to sizeof(Datum)");
StaticAssertDecl(sizeof(LONG_MIN) == sizeof(Datum), "sizeof(LONG_MIN) should be equal to sizeof(Datum)");
attr_filter->min = LONG_MAX;
attr_filter->max = LONG_MIN;
}
}
48 changes: 24 additions & 24 deletions src/backend/executor/nodeHashjoin.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static void ExecEagerFreeHashJoin(HashJoinState *node);
static void CreateRuntimeFilter(HashJoinState* hjstate);
static bool IsEqualOp(Expr *expr);
static bool CheckEqualArgs(Expr *expr, AttrNumber *lattno, AttrNumber *rattno);
static PlanState *FindTargetAttr(HashJoinState *hjstate,
static PlanState *FindTargetNode(HashJoinState *hjstate,
AttrNumber attno,
AttrNumber *lattno);
static AttrFilter *CreateAttrFilter(PlanState *target,
Expand Down Expand Up @@ -2224,7 +2224,7 @@ CreateRuntimeFilter(HashJoinState* hjstate)
if (lattno < 1 || rattno < 1)
continue;

target = FindTargetAttr(hjstate, lattno, &lattno);
target = FindTargetNode(hjstate, lattno, &lattno);
if (lattno == -1 || target == NULL || IsA(target, HashJoinState))
continue;
Assert(IsA(target, SeqScanState));
Expand Down Expand Up @@ -2273,16 +2273,11 @@ static bool
CheckEqualArgs(Expr *expr, AttrNumber *lattno, AttrNumber *rattno)
{
Var *var;
bool match;
List *args;
ListCell *lc;

if (lattno == NULL || rattno == NULL)
return false;

if (!IsA(expr, OpExpr) && !IsA(expr, FuncExpr))
return false;

if (IsA(expr, OpExpr))
args = ((OpExpr *)expr)->args;
else if (IsA(expr, FuncExpr))
Expand All @@ -2293,26 +2288,31 @@ CheckEqualArgs(Expr *expr, AttrNumber *lattno, AttrNumber *rattno)
if (!args || list_length(args) != 2)
return false;

match = false;
foreach (lc, args)
{
match = false;
/* check the first arg */
if (!IsA(linitial(args), Var))
return false;

if (!IsA(lfirst(lc), Var))
break;
var = linitial(args);
if (var->varno == INNER_VAR)
*rattno = var->varattno;
else if (var->varno == OUTER_VAR)
*lattno = var->varattno;
else
return false;

var = lfirst(lc);
if (var->varno == INNER_VAR)
*rattno = var->varattno;
else if (var->varno == OUTER_VAR)
*lattno = var->varattno;
else
break;
/* check the second arg */
if (!IsA(lsecond(args), Var))
return false;

match = true;
}
var = lsecond(args);
if (var->varno == INNER_VAR)
*rattno = var->varattno;
else if (var->varno == OUTER_VAR)
*lattno = var->varattno;
else
return false;

return match;
return true;
}

/*
Expand All @@ -2323,7 +2323,7 @@ CheckEqualArgs(Expr *expr, AttrNumber *lattno, AttrNumber *rattno)
* SeqScan <- target
*/
static PlanState *
FindTargetAttr(HashJoinState *hjstate, AttrNumber attno, AttrNumber *lattno)
FindTargetNode(HashJoinState *hjstate, AttrNumber attno, AttrNumber *lattno)
{
Var *var;
PlanState *child, *parent;
Expand Down
3 changes: 0 additions & 3 deletions src/backend/executor/nodeSeqscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ SeqNext(SeqScanState *node)
*/
while (table_scan_getnextslot(scandesc, direction, slot))
{
if (TupIsNull(slot))
return slot;

if (node->filter_in_seqscan && node->filters &&
!PassByBloomFilter(node, slot))
continue;
Expand Down

0 comments on commit 99eabb2

Please sign in to comment.