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

Function getAggregateInputInfos

src/processor/map/map_aggregate.cpp:31–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29namespace processor {
30
31static std::vector<AggregateInfo> getAggregateInputInfos(const expression_vector& keys,
32 const expression_vector& aggregates, const Schema& schema) {
33 // Collect unFlat groups from
34 std::unordered_set<f_group_pos> groupByGroupPosSet;
35 for (auto& expression : keys) {
36 groupByGroupPosSet.insert(schema.getGroupPos(*expression));
37 }
38 std::unordered_set<f_group_pos> unFlatAggregateGroupPosSet;
39 for (auto groupPos : schema.getGroupsPosInScope()) {
40 if (groupByGroupPosSet.contains(groupPos)) {
41 continue;
42 }
43 if (schema.getGroup(groupPos)->isFlat()) {
44 continue;
45 }
46 unFlatAggregateGroupPosSet.insert(groupPos);
47 }
48 std::vector<AggregateInfo> result;
49 for (auto& expression : aggregates) {
50 auto aggregateVectorPos = DataPos::getInvalidPos();
51 if (expression->getNumChildren() != 0) { // COUNT(*) has no children
52 auto child = expression->getChild(0);
53 aggregateVectorPos = DataPos{schema.getExpressionPos(*child)};
54 }
55 std::vector<data_chunk_pos_t> multiplicityChunksPos;
56 for (auto& groupPos : unFlatAggregateGroupPosSet) {
57 if (groupPos != aggregateVectorPos.dataChunkPos) {
58 multiplicityChunksPos.push_back(groupPos);
59 }
60 }
61 auto aggExpr = expression->constPtrCast<AggregateFunctionExpression>();
62 auto distinctAggKeyType = aggExpr->isDistinct() ?
63 expression->getChild(0)->getDataType().copy() :
64 LogicalType::ANY();
65 result.emplace_back(aggregateVectorPos, std::move(multiplicityChunksPos),
66 std::move(distinctAggKeyType));
67 }
68 return result;
69}
70
71static expression_vector getKeyExpressions(const expression_vector& expressions,
72 const Schema& schema, bool isFlat) {

Callers 2

mapAggregateMethod · 0.85
createHashAggregateMethod · 0.85

Calls 14

getGroupsPosInScopeMethod · 0.80
getNumChildrenMethod · 0.80
getDataTypeMethod · 0.80
emplace_backMethod · 0.80
insertMethod · 0.45
getGroupPosMethod · 0.45
containsMethod · 0.45
isFlatMethod · 0.45
getGroupMethod · 0.45
getChildMethod · 0.45
getExpressionPosMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected