| 64 | } |
| 65 | |
| 66 | void 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 | |
| 95 | void AggregateHashTable::mergeDistinctAggregateInfo() { |
| 96 | auto state = std::make_shared<DataChunkState>(); |
no test coverage detected