| 159 | } |
| 160 | |
| 161 | RowVectorPtr StreamingAggregation::createOutput(size_t numGroups) { |
| 162 | NanosecondTimer timer(&stats_.aggExtractGroupsTimeNs); |
| 163 | auto output = BaseVector::create<RowVector>(outputType_, numGroups, pool()); |
| 164 | |
| 165 | for (auto i = 0; i < groupingKeys_.size(); ++i) { |
| 166 | rows_->extractColumn(groups_.data(), numGroups, i, output->childAt(i)); |
| 167 | } |
| 168 | |
| 169 | auto numKeys = groupingKeys_.size(); |
| 170 | for (auto i = 0; i < aggregates_.size(); ++i) { |
| 171 | const auto& aggregate = aggregates_.at(i); |
| 172 | if (!aggregate.sortingKeys.empty()) { |
| 173 | continue; |
| 174 | } |
| 175 | |
| 176 | if (aggregate.distinct) { |
| 177 | continue; |
| 178 | } |
| 179 | |
| 180 | const auto& function = aggregate.function; |
| 181 | auto& result = output->childAt(numKeys + i); |
| 182 | if (isPartialOutput(step_)) { |
| 183 | function->extractAccumulators(groups_.data(), numGroups, &result); |
| 184 | } else { |
| 185 | function->extractValues(groups_.data(), numGroups, &result); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | if (sortedAggregations_) { |
| 190 | sortedAggregations_->extractValues( |
| 191 | folly::Range<char**>(groups_.data(), numGroups), output); |
| 192 | } |
| 193 | |
| 194 | for (const auto& aggregation : distinctAggregations_) { |
| 195 | if (aggregation != nullptr) { |
| 196 | aggregation->extractValues( |
| 197 | folly::Range<char**>(groups_.data(), numGroups), output); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | return output; |
| 202 | } |
| 203 | |
| 204 | void StreamingAggregation::assignGroups() { |
| 205 | auto numInput = input_->size(); |
nothing calls this directly
no test coverage detected