@Override public Operator createOperator(DriverContext driverContext) { checkState(!closed, "Factory is already closed"); OperatorContext operatorContext = driverContext.addOperatorContext(operatorId, planNodeId, HashAggregationOperator.class.getSimpleName()); HashAggregationOperator hashAggregationOperator = new HashAggregationOperator( operatorContext, groupByTypes, groupByChannels, globalAggregationGroupIds, step, produceDefaultOutput, accumulatorFactories, hashChannel, groupIdChannel, expectedGroups, maxPartialMemory, spillEnabled, memoryLimitForMerge, memoryLimitForMergeWithMemory, spillerFactory, joinCompiler, useSystemMemory); return hashAggregationOperator; }
@Override public void close() { closeAggregationBuilder(); }
if (step.isOutputPartial() || !spillEnabled || hasOrderBy() || hasDistinct()) { aggregationBuilder = new InMemoryHashAggregationBuilder( accumulatorFactories,
return getGlobalAggregationOutput(); closeAggregationBuilder(); return null;
private int getHashCapacity(Operator operator) { assertTrue(operator instanceof HashAggregationOperator); HashAggregationBuilder aggregationBuilder = ((HashAggregationOperator) operator).getAggregationBuilder(); if (aggregationBuilder == null) { return 0; } assertTrue(aggregationBuilder instanceof InMemoryHashAggregationBuilder); return ((InMemoryHashAggregationBuilder) aggregationBuilder).getCapacity(); }
long hashValue = calculateDefaultOutputHash(groupByTypes, groupIdChannel.get(), groupId); output.getBlockBuilder(channel++).writeLong(hashValue);
public HashAggregationOperator( OperatorContext operatorContext, List<Type> groupByTypes, List<Integer> groupByChannels, Step step, List<AccumulatorFactory> accumulatorFactories, Optional<Integer> maskChannel, Optional<Integer> hashChannel, int expectedGroups) { this.operatorContext = requireNonNull(operatorContext, "operatorContext is null"); requireNonNull(step, "step is null"); requireNonNull(accumulatorFactories, "accumulatorFactories is null"); requireNonNull(operatorContext, "operatorContext is null"); this.groupByTypes = ImmutableList.copyOf(groupByTypes); this.groupByChannels = ImmutableList.copyOf(groupByChannels); this.accumulatorFactories = ImmutableList.copyOf(accumulatorFactories); this.maskChannel = requireNonNull(maskChannel, "maskChannel is null"); this.hashChannel = requireNonNull(hashChannel, "hashChannel is null"); this.step = step; this.expectedGroups = expectedGroups; this.types = toTypes(groupByTypes, step, accumulatorFactories, hashChannel); }
@Override public Operator createOperator(DriverContext driverContext) { checkState(!closed, "Factory is already closed"); OperatorContext operatorContext; if (step.isOutputPartial()) { operatorContext = driverContext.addOperatorContext(operatorId, planNodeId, HashAggregationOperator.class.getSimpleName(), maxPartialMemory); } else { operatorContext = driverContext.addOperatorContext(operatorId, planNodeId, HashAggregationOperator.class.getSimpleName()); } HashAggregationOperator hashAggregationOperator = new HashAggregationOperator( operatorContext, groupByTypes, groupByChannels, step, accumulatorFactories, maskChannel, hashChannel, expectedGroups); return hashAggregationOperator; }