MCPcopy Create free account
hub / github.com/apache/cloudberry / WinRowsArePeers

Function WinRowsArePeers

src/backend/executor/nodeWindowAgg.c:3529–3566  ·  view source on GitHub ↗

* WinRowsArePeers * Compare two rows (specified by absolute position in partition) to see * if they are equal according to the ORDER BY clause. * * NB: this does not consider the window frame mode. */

Source from the content-addressed store, hash-verified

3527 * NB: this does not consider the window frame mode.
3528 */
3529bool
3530WinRowsArePeers(WindowObject winobj, int64 pos1, int64 pos2)
3531{
3532 WindowAggState *winstate;
3533 WindowAgg *node;
3534 TupleTableSlot *slot1;
3535 TupleTableSlot *slot2;
3536 bool res;
3537
3538 Assert(WindowObjectIsValid(winobj));
3539 winstate = winobj->winstate;
3540 node = (WindowAgg *) winstate->ss.ps.plan;
3541
3542 /* If no ORDER BY, all rows are peers; don't bother to fetch them */
3543 if (node->ordNumCols == 0)
3544 return true;
3545
3546 /*
3547 * Note: OK to use temp_slot_2 here because we aren't calling any
3548 * frame-related functions (those tend to clobber temp_slot_2).
3549 */
3550 slot1 = winstate->temp_slot_1;
3551 slot2 = winstate->temp_slot_2;
3552
3553 if (!window_gettupleslot(winobj, pos1, slot1))
3554 elog(ERROR, "specified position is out of window: " INT64_FORMAT,
3555 pos1);
3556 if (!window_gettupleslot(winobj, pos2, slot2))
3557 elog(ERROR, "specified position is out of window: " INT64_FORMAT,
3558 pos2);
3559
3560 res = are_peers(winstate, slot1, slot2);
3561
3562 ExecClearTuple(slot1);
3563 ExecClearTuple(slot2);
3564
3565 return res;
3566}
3567
3568/*
3569 * WinGetFuncArgInPartition

Callers 2

rank_upFunction · 0.85
window_cume_distFunction · 0.85

Calls 3

window_gettupleslotFunction · 0.85
are_peersFunction · 0.85
ExecClearTupleFunction · 0.85

Tested by

no test coverage detected