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

Function initialize_aggregates

src/backend/executor/nodeAgg.c:701–730  ·  view source on GitHub ↗

* Initialize all aggregate transition states for a new group of input values. * * If there are multiple grouping sets, we initialize only the first numReset * of them (the grouping sets are ordered so that the most specific one, which * is reset most often, is first). As a convenience, if numReset is 0, we * reinitialize all sets. * * NB: This cannot be used for hash aggregates, as for thos

Source from the content-addressed store, hash-verified

699 * When called, CurrentMemoryContext should be the per-query context.
700 */
701static void
702initialize_aggregates(AggState *aggstate,
703 AggStatePerGroup *pergroups,
704 int numReset)
705{
706 int transno;
707 int numGroupingSets = Max(aggstate->phase->numsets, 1);
708 int setno = 0;
709 int numTrans = aggstate->numtrans;
710 AggStatePerTrans transstates = aggstate->pertrans;
711
712 if (numReset == 0)
713 numReset = numGroupingSets;
714
715 for (setno = 0; setno < numReset; setno++)
716 {
717 AggStatePerGroup pergroup = pergroups[setno];
718
719 select_current_set(aggstate, setno, false);
720
721 for (transno = 0; transno < numTrans; transno++)
722 {
723 AggStatePerTrans pertrans = &transstates[transno];
724 AggStatePerGroup pergroupstate = &pergroup[transno];
725 if (!bms_is_member(transno, aggstate->aggs_used))
726 continue;
727 initialize_aggregate(aggstate, pertrans, pergroupstate);
728 }
729 }
730}
731
732/*
733 * Given new input value(s), advance the transition function of one aggregate

Callers 1

agg_retrieve_directFunction · 0.85

Calls 3

select_current_setFunction · 0.85
bms_is_memberFunction · 0.85
initialize_aggregateFunction · 0.85

Tested by

no test coverage detected