*/
hashagg_recompile_expressions(aggstate, true, true);
- LogicalTapeRewindForRead(tapeinfo->tapeset, batch->input_tapenum,
- HASHAGG_READ_BUFFER_SIZE);
for (;;)
{
TupleTableSlot *spillslot = aggstate->hash_spill_rslot;
static void
hashagg_tapeinfo_release(HashTapeInfo *tapeinfo, int tapenum)
{
+ /* rewinding frees the buffer while not in use */
LogicalTapeRewindForWrite(tapeinfo->tapeset, tapenum);
if (tapeinfo->freetapes_alloc == tapeinfo->nfreetapes)
{
for (i = 0; i < spill->npartitions; i++)
{
+ LogicalTapeSet *tapeset = aggstate->hash_tapeinfo->tapeset;
int tapenum = spill->partitions[i];
HashAggBatch *new_batch;
double cardinality;
cardinality = estimateHyperLogLog(&spill->hll_card[i]);
freeHyperLogLog(&spill->hll_card[i]);
- new_batch = hashagg_batch_new(aggstate->hash_tapeinfo->tapeset,
- tapenum, setno, spill->ntuples[i],
- cardinality, used_bits);
+ /* rewinding frees the buffer while not in use */
+ LogicalTapeRewindForRead(tapeset, tapenum,
+ HASHAGG_READ_BUFFER_SIZE);
+
+ new_batch = hashagg_batch_new(tapeset, tapenum, setno,
+ spill->ntuples[i], cardinality,
+ used_bits);
aggstate->hash_batches = lcons(new_batch, aggstate->hash_batches);
aggstate->hash_batches_used++;
}