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

Function ExecEagerFreeAgg

src/backend/executor/nodeAgg.c:5141–5205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5139}
5140
5141static void
5142ExecEagerFreeAgg(AggState *node)
5143{
5144 int transno;
5145 int numGroupingSets = Max(node->maxsets, 1);
5146 int setno;
5147
5148 /*
5149 * When ending a parallel worker, copy the statistics gathered by the
5150 * worker back into shared memory so that it can be picked up by the main
5151 * process to report in EXPLAIN ANALYZE.
5152 */
5153 if (node->shared_info && IsParallelWorker())
5154 {
5155 AggregateInstrumentation *si;
5156
5157 Assert(ParallelWorkerNumber <= node->shared_info->num_workers);
5158 si = &node->shared_info->sinstrument[ParallelWorkerNumber];
5159 si->hash_batches_used = node->hash_batches_used;
5160 si->hash_disk_used = node->hash_disk_used;
5161 si->hash_mem_peak = node->hash_mem_peak;
5162 }
5163
5164 /* Make sure we have closed any open tuplesorts */
5165 if (node->sort_in)
5166 {
5167 tuplesort_end(node->sort_in);
5168 node->sort_in = NULL;
5169 }
5170 if (node->sort_out)
5171 {
5172 tuplesort_end(node->sort_out);
5173 node->sort_out = NULL;
5174 }
5175
5176 hashagg_reset_spill_state(node);
5177
5178 if (node->hash_metacxt != NULL)
5179 {
5180 MemoryContextDelete(node->hash_metacxt);
5181 node->hash_metacxt = NULL;
5182 }
5183
5184 for (transno = 0; transno < node->numtrans; transno++)
5185 {
5186 if (!bms_is_member(transno, node->aggs_used))
5187 continue;
5188 for (setno = 0; setno < numGroupingSets; setno++)
5189 {
5190 AggStatePerTrans pertrans = &node->pertrans[transno];
5191
5192 if (pertrans->sortstates[setno])
5193 {
5194 tuplesort_end(pertrans->sortstates[setno]);
5195 pertrans->sortstates[setno] = NULL;
5196 }
5197 }
5198 }

Callers 2

ExecEndAggFunction · 0.85
ExecSquelchAggFunction · 0.85

Calls 4

tuplesort_endFunction · 0.85
bms_is_memberFunction · 0.85
ReScanExprContextFunction · 0.85

Tested by

no test coverage detected