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

Function set_append_path_locus

src/backend/optimizer/util/pathnode.c:1685–2174  ·  view source on GitHub ↗

* Set the locus of an Append or MergeAppend path. * * This modifies the 'subpaths', costs fields, and locus of 'pathnode'. * It will return false if fails to create motion for parameterized path. */

Source from the content-addressed store, hash-verified

1683 * It will return false if fails to create motion for parameterized path.
1684 */
1685static bool
1686set_append_path_locus(PlannerInfo *root, Path *pathnode, RelOptInfo *rel,
1687 List *pathkeys, int parallel_workers, bool parallel_aware)
1688{
1689 ListCell *l;
1690 CdbLocusType targetlocustype;
1691 CdbPathLocus targetlocus;
1692 int numsegments;
1693 List *subpaths;
1694 List **subpaths_out;
1695 List *new_subpaths;
1696
1697 /*
1698 * Init max_numsegments to slient compiler.
1699 * This variable is only used when result
1700 * locus is partitioned.
1701 */
1702 int max_numsegments = -1;
1703
1704 if (IsA(pathnode, AppendPath))
1705 subpaths_out = &((AppendPath *) pathnode)->subpaths;
1706 else if (IsA(pathnode, MergeAppendPath))
1707 subpaths_out = &((MergeAppendPath *) pathnode)->subpaths;
1708 else
1709 elog(ERROR, "unexpected append path type: %d", nodeTag(pathnode));
1710 subpaths = *subpaths_out;
1711 *subpaths_out = NIL;
1712
1713 /* If no subpath, any worker can execute this Append. Result has 0 rows. */
1714 if (!subpaths)
1715 {
1716 CdbPathLocus_MakeGeneral(&pathnode->locus);
1717 return true;
1718 }
1719
1720 /*
1721 * Do a first pass over the children to determine what locus the result
1722 * should have, based on the loci of the children.
1723 *
1724 * We only determine the target locus type here, the number of segments is
1725 * figured out later. We treat also all partitioned types the same for now,
1726 * using Strewn to represent them all, and figure out later if we can mark
1727 * it hashed, or if have to leave it strewn.
1728 *
1729 * We will record the max number of segments of each subpath here for later
1730 * use.
1731 */
1732 static const struct
1733 {
1734 CdbLocusType a;
1735 CdbLocusType b;
1736 CdbLocusType result;
1737 } append_locus_compatibility_table[] =
1738 {
1739 /*
1740 * If any of the children have 'outerquery' locus, bring all the subpaths
1741 * to the outer query's locus.
1742 */

Callers 2

create_append_pathFunction · 0.85
create_merge_append_pathFunction · 0.85

Calls 13

list_headFunction · 0.85
getgpsegmentCountFunction · 0.85
cdbpathlocus_equalFunction · 0.85
cdbpath_distkey_equalFunction · 0.85
make_restrictinfoFunction · 0.85
makeSegmentFilterExprFunction · 0.85
pathkeys_contained_inFunction · 0.85
bms_unionFunction · 0.85
lappendFunction · 0.85

Tested by

no test coverage detected