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

Function create_agg_path

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

* create_agg_path * Creates a pathnode that represents performing aggregation/grouping * * 'rel' is the parent relation associated with the result * 'subpath' is the path representing the source of data * 'target' is the PathTarget to be computed * 'aggstrategy' is the Agg node's basic implementation strategy * 'aggsplit' is the Agg node's aggregate-splitting mode * 'groupClause' is a li

Source from the content-addressed store, hash-verified

5043 * 'numGroups' is the estimated number of groups (1 if not grouping)
5044 */
5045AggPath *
5046create_agg_path(PlannerInfo *root,
5047 RelOptInfo *rel,
5048 Path *subpath,
5049 PathTarget *target,
5050 AggStrategy aggstrategy,
5051 AggSplit aggsplit,
5052 bool streaming,
5053 List *groupClause,
5054 List *qual,
5055 const AggClauseCosts *aggcosts,
5056 double numGroups)
5057{
5058 AggPath *pathnode = makeNode(AggPath);
5059
5060 pathnode->path.pathtype = T_Agg;
5061 pathnode->path.parent = rel;
5062 pathnode->path.pathtarget = target;
5063 /* For now, assume we are above any joins, so no parameterization */
5064 pathnode->path.param_info = NULL;
5065 pathnode->path.parallel_aware = false;
5066 pathnode->path.parallel_safe = rel->consider_parallel &&
5067 subpath->parallel_safe;
5068 pathnode->path.parallel_workers = subpath->parallel_workers;
5069 if (aggstrategy == AGG_SORTED)
5070 pathnode->path.pathkeys = subpath->pathkeys; /* preserves order */
5071 else
5072 pathnode->path.pathkeys = NIL; /* output is unordered */
5073 pathnode->path.barrierHazard = subpath->barrierHazard;
5074 pathnode->subpath = subpath;
5075 pathnode->streaming = streaming;
5076
5077 pathnode->aggstrategy = aggstrategy;
5078 pathnode->aggsplit = aggsplit;
5079 pathnode->numGroups = numGroups;
5080 pathnode->transitionSpace = aggcosts ? aggcosts->transitionSpace : 0;
5081 pathnode->groupClause = groupClause;
5082 pathnode->qual = qual;
5083 pathnode->path.motionHazard = subpath->motionHazard;
5084 pathnode->path.barrierHazard = subpath->barrierHazard;
5085
5086 cost_agg(&pathnode->path, root,
5087 aggstrategy, aggcosts,
5088 list_length(groupClause), numGroups,
5089 qual,
5090 subpath->startup_cost, subpath->total_cost,
5091 subpath->rows, subpath->pathtarget->width);
5092
5093 /* add tlist eval cost for each output row */
5094 pathnode->path.startup_cost += target->cost.startup;
5095 pathnode->path.total_cost += target->cost.startup +
5096 target->cost.per_tuple * pathnode->path.rows;
5097
5098 pathnode->path.locus = subpath->locus;
5099
5100 return pathnode;
5101}
5102

Calls 2

cost_aggFunction · 0.85
list_lengthFunction · 0.85

Tested by

no test coverage detected