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

Method executeInternal

src/processor/operator/aggregate/simple_aggregate.cpp:218–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218void 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
244void SimpleAggregate::computeAggregate(function::AggregateFunction* function, AggregateInput* input,
245 function::AggregateState* state, common::InMemOverflowBuffer& overflowBuffer) {

Callers

nothing calls this directly

Calls 10

getSharedStateFunction · 0.85
getNextTupleMethod · 0.80
isFunctionDistinctMethod · 0.80
mergeIfFullMethod · 0.80
sizeMethod · 0.45
appendDistinctMethod · 0.45
getMethod · 0.45
finalizePartitionsMethod · 0.45

Tested by

no test coverage detected