### Question:
HashAggregationOperator implements Operator { @Override public OperatorContext getOperatorContext() { return operatorContext; } HashAggregationOperator(
            OperatorContext operatorContext,
            List<Type> groupByTypes,
            List<Integer> groupByChannels,
            List<Integer> globalAggregationGroupIds,
            Step step,
            boolean produceDefaultOutput,
            List<AccumulatorFactory> accumulatorFactories,
            Optional<Integer> hashChannel,
            Optional<Integer> groupIdChannel,
            int expectedGroups,
            Optional<DataSize> maxPartialMemory,
            boolean spillEnabled,
            DataSize memoryLimitForMerge,
            DataSize memoryLimitForMergeWithMemory,
            SpillerFactory spillerFactory,
            JoinCompiler joinCompiler,
            BlockTypeOperators blockTypeOperators,
            boolean useSystemMemory); @Override OperatorContext getOperatorContext(); @Override void finish(); @Override boolean isFinished(); @Override boolean needsInput(); @Override void addInput(Page page); @Override ListenableFuture<?> startMemoryRevoke(); @Override void finishMemoryRevoke(); @Override Page getOutput(); @Override void close(); @VisibleForTesting HashAggregationBuilder getAggregationBuilder();  }### Answer:
@Test(dataProvider = "hashEnabledAndMemoryLimitForMergeValues") public void testHashAggregationMemoryReservation(boolean hashEnabled, boolean spillEnabled, boolean revokeMemoryWhenAddingPages, long memoryLimitForMerge, long memoryLimitForMergeWithMemory) { Metadata metadata = createTestMetadataManager(); InternalAggregationFunction arrayAggColumn = metadata.getAggregateFunctionImplementation( metadata.resolveFunction(QualifiedName.of("array_agg"), fromTypes(BIGINT))); List<Integer> hashChannels = Ints.asList(1); RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, hashChannels, BIGINT, BIGINT); List<Page> input = rowPagesBuilder .addSequencePage(10, 100, 0) .addSequencePage(10, 200, 0) .addSequencePage(10, 300, 0) .build(); DriverContext driverContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION, DataSize.of(10, Unit.MEGABYTE)) .addPipelineContext(0, true, true, false) .addDriverContext(); HashAggregationOperatorFactory operatorFactory = new HashAggregationOperatorFactory( 0, new PlanNodeId("test"), ImmutableList.of(BIGINT), hashChannels, ImmutableList.of(), Step.SINGLE, true, ImmutableList.of(arrayAggColumn.bind(ImmutableList.of(0), Optional.empty())), rowPagesBuilder.getHashChannel(), Optional.empty(), 100_000, Optional.of(DataSize.of(16, MEGABYTE)), spillEnabled, succinctBytes(memoryLimitForMerge), succinctBytes(memoryLimitForMergeWithMemory), spillerFactory, joinCompiler, blockTypeOperators, false); Operator operator = operatorFactory.createOperator(driverContext); toPages(operator, input.iterator(), revokeMemoryWhenAddingPages); assertEquals(operator.getOperatorContext().getOperatorStats().getUserMemoryReservation().toBytes(), 0); }