MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / mapAggregate

Method mapAggregate

src/processor/map/map_aggregate.cpp:246–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246std::unique_ptr<PhysicalOperator> PlanMapper::mapAggregate(const LogicalOperator* logicalOperator) {
247 auto& agg = logicalOperator->constCast<LogicalAggregate>();
248 if (auto packedFilteredCount = tryMapPackedFilteredCount(*this, clientContext, agg)) {
249 return packedFilteredCount;
250 }
251 auto aggregates = agg.getAggregates();
252 auto outSchema = agg.getSchema();
253 auto child = agg.getChild(0).get();
254 auto inSchema = child->getSchema();
255 auto prevOperator = mapOperator(child);
256 if (agg.hasKeys()) {
257 return createHashAggregate(agg.getKeys(), agg.getDependentKeys(), aggregates, inSchema,
258 outSchema, std::move(prevOperator));
259 }
260 auto aggFunctions = getAggFunctions(aggregates);
261 auto aggOutputPos = getDataPos(aggregates, *outSchema);
262 auto aggregateInputInfos = getAggregateInputInfos(agg.getAllKeys(), aggregates, *inSchema);
263 auto sharedState =
264 make_shared<SimpleAggregateSharedState>(clientContext, aggFunctions, aggregateInputInfos);
265 auto printInfo = std::make_unique<SimpleAggregatePrintInfo>(aggregates);
266 auto aggregate = make_unique<SimpleAggregate>(sharedState, std::move(aggFunctions),
267 copyVector(aggregateInputInfos), std::move(prevOperator), getOperatorID(),
268 printInfo->copy());
269 aggregate->setDescriptor(std::make_unique<ResultSetDescriptor>(inSchema));
270 auto finalizer = std::make_unique<SimpleAggregateFinalize>(sharedState,
271 std::move(aggregateInputInfos), getOperatorID(), printInfo->copy());
272 finalizer->addChild(std::move(aggregate));
273 aggFunctions = getAggFunctions(aggregates);
274 auto scan = std::make_unique<SimpleAggregateScan>(sharedState,
275 AggregateScanInfo{std::move(aggOutputPos), getMoveAggResultToVectorFuncs(aggFunctions)},
276 getOperatorID(), printInfo->copy());
277 scan->addChild(std::move(finalizer));
278 return scan;
279}
280
281static FactorizedTableSchema getFactorizedTableSchema(const expression_vector& flatKeys,
282 const expression_vector& unFlatKeys, const expression_vector& payloads,

Callers

nothing calls this directly

Calls 15

getAggFunctionsFunction · 0.85
getAggregateInputInfosFunction · 0.85
copyVectorFunction · 0.85
getOperatorIDFunction · 0.85
getAggregatesMethod · 0.80
hasKeysMethod · 0.80
getDependentKeysMethod · 0.80
getAllKeysMethod · 0.80
getMethod · 0.45
getChildMethod · 0.45

Tested by

no test coverage detected