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

Function hashagg_batch_read

src/backend/executor/nodeAgg.c:3332–3373  ·  view source on GitHub ↗

* read_spilled_tuple * read the next tuple from a batch's tape. Return NULL if no more. */

Source from the content-addressed store, hash-verified

3330 * read the next tuple from a batch's tape. Return NULL if no more.
3331 */
3332static MinimalTuple
3333hashagg_batch_read(HashAggBatch *batch, uint32 *hashp)
3334{
3335 LogicalTapeSet *tapeset = batch->tapeset;
3336 int tapenum = batch->input_tapenum;
3337 MinimalTuple tuple;
3338 uint32 t_len;
3339 size_t nread;
3340 uint32 hash;
3341
3342 nread = LogicalTapeRead(tapeset, tapenum, &hash, sizeof(uint32));
3343 if (nread == 0)
3344 return NULL;
3345 if (nread != sizeof(uint32))
3346 ereport(ERROR,
3347 (errcode_for_file_access(),
3348 errmsg("unexpected EOF for tape %d: requested %zu bytes, read %zu bytes",
3349 tapenum, sizeof(uint32), nread)));
3350 if (hashp != NULL)
3351 *hashp = hash;
3352
3353 nread = LogicalTapeRead(tapeset, tapenum, &t_len, sizeof(t_len));
3354 if (nread != sizeof(uint32))
3355 ereport(ERROR,
3356 (errcode_for_file_access(),
3357 errmsg("unexpected EOF for tape %d: requested %zu bytes, read %zu bytes",
3358 tapenum, sizeof(uint32), nread)));
3359
3360 tuple = (MinimalTuple) palloc(t_len);
3361 tuple->t_len = t_len;
3362
3363 nread = LogicalTapeRead(tapeset, tapenum,
3364 (void *) ((char *) tuple + sizeof(uint32)),
3365 t_len - sizeof(uint32));
3366 if (nread != t_len - sizeof(uint32))
3367 ereport(ERROR,
3368 (errcode_for_file_access(),
3369 errmsg("unexpected EOF for tape %d: requested %zu bytes, read %zu bytes",
3370 tapenum, t_len - sizeof(uint32), nread)));
3371
3372 return tuple;
3373}
3374
3375/*
3376 * hashagg_finish_initial_spills

Callers 1

agg_refill_hash_tableFunction · 0.85

Calls 4

LogicalTapeReadFunction · 0.85
errcode_for_file_accessFunction · 0.50
errmsgFunction · 0.50
pallocFunction · 0.50

Tested by

no test coverage detected