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

Method merge

src/processor/operator/aggregate/aggregate_hash_table.cpp:66–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void AggregateHashTable::merge(FactorizedTable&& table) {
67 DASSERT(*table.getTableSchema() == *getTableSchema());
68 resizeHashTableIfNecessary(table.getNumTuples());
69
70 uint64_t startTupleIdx = 0;
71 while (startTupleIdx < table.getNumTuples()) {
72 auto numTuplesToScan =
73 std::min(table.getNumTuples() - startTupleIdx, DEFAULT_VECTOR_CAPACITY);
74 findHashSlots(table, startTupleIdx, numTuplesToScan);
75 auto aggregateStateOffset = aggStateColOffsetInFT;
76 for (auto& aggregateFunction : aggregateFunctions) {
77 // We'll update the distinct state at the end.
78 // The distinct data gets merged separately, and only after the main data so that
79 // we can guarantee that there is a group available in teh hash table for any given
80 // distinct tuple.
81 if (!aggregateFunction.isDistinct) {
82 for (auto i = 0u; i < numTuplesToScan; i++) {
83 aggregateFunction.combineState(hashSlotsToUpdateAggState[i]->getEntry() +
84 aggregateStateOffset,
85 table.getTuple(startTupleIdx + i) + aggregateStateOffset,
86 factorizedTable->getInMemOverflowBuffer());
87 }
88 }
89 aggregateStateOffset += aggregateFunction.getAggregateStateSize();
90 }
91 startTupleIdx += numTuplesToScan;
92 }
93}
94
95void AggregateHashTable::mergeDistinctAggregateInfo() {
96 auto state = std::make_shared<DataChunkState>();

Callers 3

mergeIntoMethod · 0.45
finalizePartitionsMethod · 0.45

Calls 7

getTableSchemaFunction · 0.85
combineStateMethod · 0.80
getAggregateStateSizeMethod · 0.80
getTableSchemaMethod · 0.45
getNumTuplesMethod · 0.45
getEntryMethod · 0.45
getTupleMethod · 0.45

Tested by

no test coverage detected