| 1353 | SelectivityVector selections(groupOfRows.size()); |
| 1354 | auto& accumulators = container->accumulators(); |
| 1355 | BOLT_CHECK_EQ(accumulators.size(), aggregates_.size()); |
| 1356 | for (auto i = 0; i < aggregates_.size(); ++i) { |
| 1357 | // extract accumulate |
| 1358 | std::vector<VectorPtr> args{BaseVector::create( |
| 1359 | accumulators[i].spillType(), groupOfRows.size(), &pool_)}; |
| 1360 | accumulators[i].extractForSpill( |
| 1361 | folly::Range<char**>(rows.data(), groupOfRows.size()), args[0]); |
| 1362 | // update accumulate to groups |
| 1363 | aggregates_[i].function->addIntermediateResults( |
| 1364 | groupOfRows.data(), selections, args, false); |
| 1365 | } |
| 1366 | rows.clear(); |
| 1367 | groupOfRows.clear(); |
| 1368 | } |
| 1369 | |
| 1370 | void GroupingSet::outputUniqueGroups( |
| 1371 | std::vector<char*>& uniqueRows, |
| 1372 | const RowVectorPtr& uniqueRes, |
| 1373 | size_t& uniqueCount, |
| 1374 | size_t& estimateUniqueBytesPerRow) { |
| 1375 | if (!uniqueRows.empty()) { |
| 1376 | NanosecondTimer aggTimer(&stats_.aggOutputUpdateTimeNs); |
| 1377 | if (uniqueRows.size() + uniqueCount > uniqueRes->size()) { |
| 1378 | uniqueRes->resize(uniqueRows.size() + uniqueCount); |
| 1379 | } |
| 1380 | auto* container = spiller_->container(); |
| 1381 | for (auto i = 0; i < keyChannels_.size(); ++i) { |
| 1382 | rowToColumnVector( |
| 1383 | uniqueRows.data(), |
| 1384 | uniqueRows.size(), |
| 1385 | container->columns().at(i), |
| 1386 | uniqueCount, |
| 1387 | uniqueRes->childAt(i)); |
| 1388 | } |
| 1389 | |
| 1390 | auto& accumulators = container->accumulators(); |
| 1391 | BOLT_CHECK_EQ(accumulators.size(), aggregates_.size()); |
| 1392 | for (auto i = 0; i < aggregates_.size(); ++i) { |
| 1393 | // extract accumulate |
| 1394 | auto aggCol = uniqueRes->childAt(i + keyChannels_.size()); |
| 1395 | VectorPtr args = BaseVector::create( |
| 1396 | isPartial_ ? accumulators[i].spillType() |
| 1397 | : accumulators[i].finalOutputType(), |
| 1398 | uniqueRows.size(), |
| 1399 | &pool_); |
| 1400 | BOLT_CHECK(aggCol->type()->equivalent(*args->type())); |
| 1401 | isPartial_ |
| 1402 | ? accumulators[i].extractForSpill( |
| 1403 | folly::Range<char**>(uniqueRows.data(), uniqueRows.size()), |
| 1404 | args) |
| 1405 | : accumulators[i].extractForOutput( |
nothing calls this directly
no test coverage detected