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

Function ExecHashJoinGetSavedTuple

src/backend/executor/nodeHashjoin.c:1619–1665  ·  view source on GitHub ↗

* ExecHashJoinGetSavedTuple * read the next tuple from a batch file. Return NULL if no more. * * On success, *hashvalue is set to the tuple's hash value, and the tuple * itself is stored in the given slot. */

Source from the content-addressed store, hash-verified

1617 * itself is stored in the given slot.
1618 */
1619static TupleTableSlot *
1620ExecHashJoinGetSavedTuple(HashJoinState *hjstate,
1621 BufFile *file,
1622 uint32 *hashvalue,
1623 TupleTableSlot *tupleSlot)
1624{
1625 uint32 header[2];
1626 size_t nread;
1627 MinimalTuple tuple;
1628
1629 /*
1630 * We check for interrupts here because this is typically taken as an
1631 * alternative code path to an ExecProcNode() call, which would include
1632 * such a check.
1633 */
1634 CHECK_FOR_INTERRUPTS();
1635
1636 /*
1637 * Since both the hash value and the MinimalTuple length word are uint32,
1638 * we can read them both in one BufFileRead() call without any type
1639 * cheating.
1640 */
1641 nread = BufFileRead(file, (void *) header, sizeof(header));
1642 if (nread == 0) /* end of file */
1643 {
1644 ExecClearTuple(tupleSlot);
1645 return NULL;
1646 }
1647 if (nread != sizeof(header))
1648 ereport(ERROR,
1649 (errcode_for_file_access(),
1650 errmsg("could not read from hash-join temporary file: read only %zu of %zu bytes",
1651 nread, sizeof(header))));
1652 *hashvalue = header[0];
1653 tuple = (MinimalTuple) palloc(header[1]);
1654 tuple->t_len = header[1];
1655 nread = BufFileRead(file,
1656 (void *) ((char *) tuple + sizeof(uint32)),
1657 header[1] - sizeof(uint32));
1658 if (nread != header[1] - sizeof(uint32))
1659 ereport(ERROR,
1660 (errcode_for_file_access(),
1661 errmsg("could not read from hash-join temporary file: read only %zu of %zu bytes",
1662 nread, header[1] - sizeof(uint32))));
1663 ExecForceStoreMinimalTuple(tuple, tupleSlot, true);
1664 return tupleSlot;
1665}
1666
1667
1668void

Callers 2

Calls 6

BufFileReadFunction · 0.85
ExecClearTupleFunction · 0.85
errcode_for_file_accessFunction · 0.50
errmsgFunction · 0.50
pallocFunction · 0.50

Tested by

no test coverage detected