| 44 | namespace bytedance::bolt::exec { |
| 45 | |
| 46 | HashAggregation::HashAggregation( |
| 47 | int32_t operatorId, |
| 48 | DriverCtx* driverCtx, |
| 49 | const std::shared_ptr<const core::AggregationNode>& aggregationNode) |
| 50 | : Operator( |
| 51 | driverCtx, |
| 52 | aggregationNode->outputType(), |
| 53 | operatorId, |
| 54 | aggregationNode->id(), |
| 55 | aggregationNode->step() == core::AggregationNode::Step::kPartial |
| 56 | ? "PartialAggregation" |
| 57 | : "Aggregation", |
| 58 | aggregationNode->canSpill(driverCtx->queryConfig()) |
| 59 | ? driverCtx->makeSpillConfig(operatorId) |
| 60 | : std::nullopt), |
| 61 | aggregationNode_(aggregationNode), |
| 62 | isPartialOutput_(isPartialOutput(aggregationNode->step())), |
| 63 | isPartialStep_( |
| 64 | aggregationNode->step() == core::AggregationNode::Step::kPartial), |
| 65 | isGlobal_(aggregationNode->groupingKeys().empty()), |
| 66 | isDistinct_(!isGlobal_ && aggregationNode->aggregates().empty()), |
| 67 | maxExtendedPartialAggregationMemoryUsage_( |
| 68 | driverCtx->queryConfig().maxExtendedPartialAggregationMemoryUsage()), |
| 69 | abandonPartialAggregationMinRows_( |
| 70 | driverCtx->queryConfig().abandonPartialAggregationMinRows()), |
| 71 | abandonPartialAggregationMinPct_( |
| 72 | driverCtx->queryConfig().abandonPartialAggregationMinPct()), |
| 73 | abandonPartialAggregationMinFinalPct_( |
| 74 | driverCtx->queryConfig().abandonPartialAggregationMinFinalPct()), |
| 75 | partialAggregationSpillMaxPct_( |
| 76 | driverCtx->queryConfig().partialAggregationSpillMaxPct()), |
| 77 | maxPartialAggregationMemoryUsage_( |
| 78 | driverCtx->queryConfig().maxPartialAggregationMemoryUsage()), |
| 79 | preferPartialSpill_( |
| 80 | driverCtx->queryConfig().preferPartialAggregationSpill()), |
| 81 | skippedDataSizeThreshold_( |
| 82 | driverCtx->queryConfig().adaptiveSkippedDataSizeThreshold()), |
| 83 | minOutputRows_((driverCtx->queryConfig().minOutputBatchRows())) { |
| 84 | if (canSpill()) { |
| 85 | BOLT_CHECK( |
| 86 | partialAggregationSpillMaxPct_ <= abandonPartialAggregationMinPct_ && |
| 87 | partialAggregationSpillMaxPct_ <= |
| 88 | abandonPartialAggregationMinFinalPct_, |
| 89 | "partialAggregationSpillMaxPct_ = {}, abandonPartialAggregationMinPct_ = {}, abandonPartialAggregationMinFinalPct_ = {}", |
| 90 | partialAggregationSpillMaxPct_, |
| 91 | abandonPartialAggregationMinPct_, |
| 92 | abandonPartialAggregationMinFinalPct_); |
| 93 | adaptiveAdjustment_ = skippedDataSizeThreshold_ > 0; |
| 94 | } |
| 95 | this->setRuntimeMetric( |
| 96 | OperatorMetricKey::kCanUsedToEstimateHashBuildPartitionNum, "true"); |
| 97 | this->setRuntimeMetric( |
| 98 | OperatorMetricKey::kTotalRowCount, folly::to<std::string>(0)); |
| 99 | this->setRuntimeMetric( |
| 100 | OperatorMetricKey::kHasBeenProcessedRowCount, folly::to<std::string>(0)); |
| 101 | } |
| 102 | |
| 103 | void HashAggregation::initialize() { |
nothing calls this directly
no test coverage detected