| 216 | } |
| 217 | |
| 218 | void SimpleAggregate::executeInternal(ExecutionContext* context) { |
| 219 | InMemOverflowBuffer localOverflowBuffer(storage::MemoryManager::Get(*context->clientContext)); |
| 220 | while (children[0]->getNextTuple(context)) { |
| 221 | for (auto i = 0u; i < aggregateFunctions.size(); i++) { |
| 222 | auto aggregateFunction = &aggregateFunctions[i]; |
| 223 | if (aggregateFunction->isFunctionDistinct()) { |
| 224 | // Just add distinct value to the hash table. We'll calculate the aggregate state |
| 225 | // once it's been merged into the shared state |
| 226 | distinctHashTables[i]->appendDistinct(std::vector<ValueVector*>{}, |
| 227 | aggInputs[i].aggregateVector, aggInputs[i].aggregateVector->state.get()); |
| 228 | } else { |
| 229 | computeAggregate(aggregateFunction, &aggInputs[i], localAggregateStates[i].get(), |
| 230 | localOverflowBuffer); |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | if (getSharedState().hasDistinct) { |
| 235 | for (auto& hashTable : distinctHashTables) { |
| 236 | if (hashTable) { |
| 237 | hashTable->mergeIfFull(0 /*tuplesToAdd*/, true /*mergeAll*/); |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | getSharedState().combineAggregateStates(localAggregateStates, std::move(localOverflowBuffer)); |
| 242 | } |
| 243 | |
| 244 | void SimpleAggregate::computeAggregate(function::AggregateFunction* function, AggregateInput* input, |
| 245 | function::AggregateState* state, common::InMemOverflowBuffer& overflowBuffer) { |
nothing calls this directly
no test coverage detected