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

Function build_hash_table

src/backend/executor/nodeAgg.c:1564–1597  ·  view source on GitHub ↗

* Build a single hashtable for this grouping set. */

Source from the content-addressed store, hash-verified

1562 * Build a single hashtable for this grouping set.
1563 */
1564static void
1565build_hash_table(AggState *aggstate, int setno, long nbuckets)
1566{
1567 AggStatePerHash perhash = &aggstate->perhash[setno];
1568 MemoryContext metacxt = aggstate->hash_metacxt;
1569 MemoryContext hashcxt = aggstate->hashcontext->ecxt_per_tuple_memory;
1570 MemoryContext tmpcxt = aggstate->tmpcontext->ecxt_per_tuple_memory;
1571 Size additionalsize;
1572
1573 Assert(aggstate->aggstrategy == AGG_HASHED ||
1574 aggstate->aggstrategy == AGG_MIXED);
1575
1576 /*
1577 * Used to make sure initial hash table allocation does not exceed
1578 * hash_mem. Note that the estimate does not include space for
1579 * pass-by-reference transition data values, nor for the representative
1580 * tuple of each group.
1581 */
1582 additionalsize = aggstate->numtrans * sizeof(AggStatePerGroupData);
1583
1584 perhash->hashtable = BuildTupleHashTableExt(&aggstate->ss.ps,
1585 perhash->hashslot->tts_tupleDescriptor,
1586 perhash->numCols,
1587 perhash->hashGrpColIdxHash,
1588 perhash->eqfuncoids,
1589 perhash->hashfunctions,
1590 perhash->aggnode->grpCollations,
1591 nbuckets,
1592 additionalsize,
1593 metacxt,
1594 hashcxt,
1595 tmpcxt,
1596 DO_AGGSPLIT_SKIPFINAL(aggstate->aggsplit));
1597}
1598
1599/*
1600 * Compute columns that actually need to be stored in hashtable entries. The

Callers 1

build_hash_tablesFunction · 0.70

Calls 1

BuildTupleHashTableExtFunction · 0.85

Tested by

no test coverage detected