| 61 | } |
| 62 | |
| 63 | void StreamingAggregation::initialize() { |
| 64 | Operator::initialize(); |
| 65 | |
| 66 | auto numKeys = aggregationNode_->groupingKeys().size(); |
| 67 | decodedKeys_.resize(numKeys); |
| 68 | |
| 69 | auto inputType = aggregationNode_->sources()[0]->outputType(); |
| 70 | |
| 71 | std::vector<TypePtr> groupingKeyTypes; |
| 72 | groupingKeyTypes.reserve(numKeys); |
| 73 | |
| 74 | groupingKeys_.reserve(numKeys); |
| 75 | for (const auto& key : aggregationNode_->groupingKeys()) { |
| 76 | auto channel = exprToChannel(key.get(), inputType); |
| 77 | groupingKeys_.push_back(channel); |
| 78 | groupingKeyTypes.push_back(inputType->childAt(channel)); |
| 79 | } |
| 80 | |
| 81 | std::shared_ptr<core::ExpressionEvaluator> expressionEvaluator; |
| 82 | aggregates_ = toAggregateInfo( |
| 83 | *aggregationNode_, *operatorCtx_, numKeys, expressionEvaluator, true); |
| 84 | |
| 85 | // Setup SortedAggregations. |
| 86 | sortedAggregations_ = |
| 87 | SortedAggregations::create(aggregates_, inputType, pool()); |
| 88 | |
| 89 | distinctAggregations_.reserve(aggregates_.size()); |
| 90 | for (auto& aggregate : aggregates_) { |
| 91 | if (aggregate.distinct) { |
| 92 | distinctAggregations_.emplace_back( |
| 93 | DistinctAggregations::create({&aggregate}, inputType, pool())); |
| 94 | } else { |
| 95 | distinctAggregations_.push_back(nullptr); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | masks_ = std::make_unique<AggregationMasks>(extractMaskChannels(aggregates_)); |
| 100 | rows_ = makeRowContainer(groupingKeyTypes); |
| 101 | |
| 102 | initializeAggregates(numKeys); |
| 103 | |
| 104 | aggregationNode_.reset(); |
| 105 | } |
| 106 | |
| 107 | void StreamingAggregation::close() { |
| 108 | if (rows_ != nullptr) { |
nothing calls this directly
no test coverage detected