@@ -1491,7 +1491,7 @@ build_hash_tables(AggState *aggstate)
1491
1491
#ifdef USE_INJECTION_POINTS
1492
1492
if (IS_INJECTION_POINT_ATTACHED ("hash-aggregate-oversize-table" ))
1493
1493
{
1494
- nbuckets = memory / sizeof ( TupleHashEntryData );
1494
+ nbuckets = memory / TupleHashEntrySize ( );
1495
1495
INJECTION_POINT_CACHED ("hash-aggregate-oversize-table" );
1496
1496
}
1497
1497
#endif
@@ -1724,7 +1724,7 @@ hash_agg_entry_size(int numTrans, Size tupleWidth, Size transitionSpace)
1724
1724
transitionChunkSize = 0 ;
1725
1725
1726
1726
return
1727
- sizeof ( TupleHashEntryData ) +
1727
+ TupleHashEntrySize ( ) +
1728
1728
tupleChunkSize +
1729
1729
pergroupChunkSize +
1730
1730
transitionChunkSize ;
@@ -1988,7 +1988,7 @@ hash_agg_update_metrics(AggState *aggstate, bool from_tape, int npartitions)
1988
1988
if (aggstate -> hash_ngroups_current > 0 )
1989
1989
{
1990
1990
aggstate -> hashentrysize =
1991
- sizeof ( TupleHashEntryData ) +
1991
+ TupleHashEntrySize ( ) +
1992
1992
(hashkey_mem / (double ) aggstate -> hash_ngroups_current );
1993
1993
}
1994
1994
}
@@ -2147,11 +2147,7 @@ initialize_hash_entry(AggState *aggstate, TupleHashTable hashtable,
2147
2147
if (aggstate -> numtrans == 0 )
2148
2148
return ;
2149
2149
2150
- pergroup = (AggStatePerGroup )
2151
- MemoryContextAlloc (hashtable -> tablecxt ,
2152
- sizeof (AggStatePerGroupData ) * aggstate -> numtrans );
2153
-
2154
- entry -> additional = pergroup ;
2150
+ pergroup = (AggStatePerGroup ) TupleHashEntryGetAdditional (hashtable , entry );
2155
2151
2156
2152
/*
2157
2153
* Initialize aggregates for new tuple group, lookup_hash_entries()
@@ -2213,7 +2209,7 @@ lookup_hash_entries(AggState *aggstate)
2213
2209
{
2214
2210
if (isnew )
2215
2211
initialize_hash_entry (aggstate , hashtable , entry );
2216
- pergroup [setno ] = entry -> additional ;
2212
+ pergroup [setno ] = TupleHashEntryGetAdditional ( hashtable , entry ) ;
2217
2213
}
2218
2214
else
2219
2215
{
@@ -2748,6 +2744,7 @@ agg_refill_hash_table(AggState *aggstate)
2748
2744
{
2749
2745
TupleTableSlot * spillslot = aggstate -> hash_spill_rslot ;
2750
2746
TupleTableSlot * hashslot = perhash -> hashslot ;
2747
+ TupleHashTable hashtable = perhash -> hashtable ;
2751
2748
TupleHashEntry entry ;
2752
2749
MinimalTuple tuple ;
2753
2750
uint32 hash ;
@@ -2766,14 +2763,14 @@ agg_refill_hash_table(AggState *aggstate)
2766
2763
prepare_hash_slot (perhash ,
2767
2764
aggstate -> tmpcontext -> ecxt_outertuple ,
2768
2765
hashslot );
2769
- entry = LookupTupleHashEntryHash (perhash -> hashtable , hashslot ,
2766
+ entry = LookupTupleHashEntryHash (hashtable , hashslot ,
2770
2767
p_isnew , hash );
2771
2768
2772
2769
if (entry != NULL )
2773
2770
{
2774
2771
if (isnew )
2775
- initialize_hash_entry (aggstate , perhash -> hashtable , entry );
2776
- aggstate -> hash_pergroup [batch -> setno ] = entry -> additional ;
2772
+ initialize_hash_entry (aggstate , hashtable , entry );
2773
+ aggstate -> hash_pergroup [batch -> setno ] = TupleHashEntryGetAdditional ( hashtable , entry ) ;
2777
2774
advance_aggregates (aggstate );
2778
2775
}
2779
2776
else
@@ -2865,7 +2862,7 @@ agg_retrieve_hash_table_in_memory(AggState *aggstate)
2865
2862
ExprContext * econtext ;
2866
2863
AggStatePerAgg peragg ;
2867
2864
AggStatePerGroup pergroup ;
2868
- TupleHashEntryData * entry ;
2865
+ TupleHashEntry entry ;
2869
2866
TupleTableSlot * firstSlot ;
2870
2867
TupleTableSlot * result ;
2871
2868
AggStatePerHash perhash ;
@@ -2892,14 +2889,15 @@ agg_retrieve_hash_table_in_memory(AggState *aggstate)
2892
2889
for (;;)
2893
2890
{
2894
2891
TupleTableSlot * hashslot = perhash -> hashslot ;
2892
+ TupleHashTable hashtable = perhash -> hashtable ;
2895
2893
int i ;
2896
2894
2897
2895
CHECK_FOR_INTERRUPTS ();
2898
2896
2899
2897
/*
2900
2898
* Find the next entry in the hash table
2901
2899
*/
2902
- entry = ScanTupleHashTable (perhash -> hashtable , & perhash -> hashiter );
2900
+ entry = ScanTupleHashTable (hashtable , & perhash -> hashiter );
2903
2901
if (entry == NULL )
2904
2902
{
2905
2903
int nextset = aggstate -> current_set + 1 ;
@@ -2914,7 +2912,7 @@ agg_retrieve_hash_table_in_memory(AggState *aggstate)
2914
2912
2915
2913
perhash = & aggstate -> perhash [aggstate -> current_set ];
2916
2914
2917
- ResetTupleHashIterator (perhash -> hashtable , & perhash -> hashiter );
2915
+ ResetTupleHashIterator (hashtable , & perhash -> hashiter );
2918
2916
2919
2917
continue ;
2920
2918
}
@@ -2937,7 +2935,7 @@ agg_retrieve_hash_table_in_memory(AggState *aggstate)
2937
2935
* Transform representative tuple back into one with the right
2938
2936
* columns.
2939
2937
*/
2940
- ExecStoreMinimalTuple (entry -> firstTuple , hashslot , false);
2938
+ ExecStoreMinimalTuple (TupleHashEntryGetTuple ( entry ) , hashslot , false);
2941
2939
slot_getallattrs (hashslot );
2942
2940
2943
2941
ExecClearTuple (firstSlot );
@@ -2953,7 +2951,7 @@ agg_retrieve_hash_table_in_memory(AggState *aggstate)
2953
2951
}
2954
2952
ExecStoreVirtualTuple (firstSlot );
2955
2953
2956
- pergroup = (AggStatePerGroup ) entry -> additional ;
2954
+ pergroup = (AggStatePerGroup ) TupleHashEntryGetAdditional ( hashtable , entry ) ;
2957
2955
2958
2956
/*
2959
2957
* Use the representative input tuple for any references to
0 commit comments