protected void createAndRunAggregators()

in computer-test/src/main/java/org/apache/hugegraph/computer/core/worker/MockComputation.java [128:318]


    protected void createAndRunAggregators(WorkerContext context) {
        // AGGR_CUSTOM_INT
        this.aggrCustomInt = context.createAggregator(
                             MockMasterComputation.AGGR_CUSTOM_INT);

        Assert.assertEquals(new IntValue(0),
                            this.aggrCustomInt.aggregatedValue());

        this.aggrCustomInt.aggregateValue(1);
        Assert.assertEquals(new IntValue(1),
                            this.aggrCustomInt.aggregatedValue());

        this.aggrCustomInt.aggregateValue(new IntValue(1));
        Assert.assertEquals(new IntValue(2),
                            this.aggrCustomInt.aggregatedValue());

        this.aggrCustomInt.aggregateValue(3);
        Assert.assertEquals(new IntValue(5),
                            this.aggrCustomInt.aggregatedValue());

        // AGGR_CUSTOM_FLOAT
        this.aggrCustomFloat = context.createAggregator(
                               MockMasterComputation.AGGR_CUSTOM_FLOAT);

        Assert.assertEquals(new FloatValue(0f),
                            this.aggrCustomFloat.aggregatedValue());

        this.aggrCustomFloat.aggregateValue(1f);
        Assert.assertEquals(new FloatValue(1f),
                            this.aggrCustomFloat.aggregatedValue());

        this.aggrCustomFloat.aggregateValue(new FloatValue(1f));
        Assert.assertEquals(new FloatValue(2f),
                            this.aggrCustomFloat.aggregatedValue());

        this.aggrCustomFloat.aggregateValue(3.2f);
        Assert.assertEquals(new FloatValue(5.2f),
                            this.aggrCustomFloat.aggregatedValue());

        // AGGR_INT_SUM
        this.aggrIntSum = context.createAggregator(
                          MockMasterComputation.AGGR_INT_SUM);

        Assert.assertEquals(new IntValue(0),
                            this.aggrIntSum.aggregatedValue());

        this.aggrIntSum.aggregateValue(1);
        Assert.assertEquals(new IntValue(1),
                            this.aggrIntSum.aggregatedValue());

        this.aggrIntSum.aggregateValue(new IntValue(1));
        Assert.assertEquals(new IntValue(2),
                            this.aggrIntSum.aggregatedValue());

        this.aggrIntSum.aggregateValue(3);
        Assert.assertEquals(new IntValue(5),
                            this.aggrIntSum.aggregatedValue());

        // AGGR_INT_MAX
        this.aggrIntMax = context.createAggregator(
                          MockMasterComputation.AGGR_INT_MAX);

        Assert.assertEquals(new IntValue(0),
                            this.aggrIntMax.aggregatedValue());

        this.aggrIntMax.aggregateValue(1);
        Assert.assertEquals(new IntValue(1),
                            this.aggrIntMax.aggregatedValue());

        this.aggrIntMax.aggregateValue(8);
        Assert.assertEquals(new IntValue(8),
                            this.aggrIntMax.aggregatedValue());

        this.aggrIntMax.aggregateValue(3);
        Assert.assertEquals(new IntValue(8),
                            this.aggrIntMax.aggregatedValue());

        // AGGR_LONG_SUM
        this.aggrLongSum = context.createAggregator(
                           MockMasterComputation.AGGR_LONG_SUM);

        Assert.assertEquals(new LongValue(0L),
                            this.aggrLongSum.aggregatedValue());

        this.aggrLongSum.aggregateValue(1L);
        Assert.assertEquals(new LongValue(1L),
                            this.aggrLongSum.aggregatedValue());

        this.aggrLongSum.aggregateValue(new LongValue(1L));
        Assert.assertEquals(new LongValue(2L),
                            this.aggrLongSum.aggregatedValue());

        this.aggrLongSum.aggregateValue(3L);
        Assert.assertEquals(new LongValue(5L),
                            this.aggrLongSum.aggregatedValue());

        // AGGR_LONG_MAX
        this.aggrLongMax = context.createAggregator(
                           MockMasterComputation.AGGR_LONG_MAX);

        Assert.assertEquals(new LongValue(0L),
                            this.aggrLongMax.aggregatedValue());

        this.aggrLongMax.aggregateValue(1L);
        Assert.assertEquals(new LongValue(1L),
                            this.aggrLongMax.aggregatedValue());

        this.aggrLongMax.aggregateValue(8L);
        Assert.assertEquals(new LongValue(8L),
                            this.aggrLongMax.aggregatedValue());

        this.aggrLongMax.aggregateValue(3L);
        Assert.assertEquals(new LongValue(8L),
                            this.aggrLongMax.aggregatedValue());

        // AGGR_FLOAT_SUM
        this.aggrFloatSum = context.createAggregator(
                            MockMasterComputation.AGGR_FLOAT_SUM);

        Assert.assertEquals(new FloatValue(0.0f),
                            this.aggrFloatSum.aggregatedValue());

        this.aggrFloatSum.aggregateValue(1.1f);
        Assert.assertEquals(new FloatValue(1.1f),
                            this.aggrFloatSum.aggregatedValue());

        this.aggrFloatSum.aggregateValue(2.3f);
        Assert.assertEquals(new FloatValue(3.4f),
                            this.aggrFloatSum.aggregatedValue());

        this.aggrFloatSum.aggregateValue(7.0f);
        Assert.assertEquals(new FloatValue(10.4f),
                            this.aggrFloatSum.aggregatedValue());

        // AGGR_FLOAT_MIN
        this.aggrFloatMin = context.createAggregator(
                            MockMasterComputation.AGGR_FLOAT_MIN);

        Assert.assertEquals(new FloatValue(0.0f),
                            this.aggrFloatMin.aggregatedValue());

        this.aggrFloatMin.aggregateValue(1.1f);
        Assert.assertEquals(new FloatValue(0.0f),
                            this.aggrFloatMin.aggregatedValue());

        this.aggrFloatMin.aggregateValue(-10.0f);
        Assert.assertEquals(new FloatValue(-10.0f),
                            this.aggrFloatMin.aggregatedValue());

        this.aggrFloatMin.aggregateValue(-4.0f);
        Assert.assertEquals(new FloatValue(-10.0f),
                            this.aggrFloatMin.aggregatedValue());

        // AGGR_DOUBLE_SUM
        this.aggrDoubleSum = context.createAggregator(
                             MockMasterComputation.AGGR_DOUBLE_SUM);

        Assert.assertEquals(new DoubleValue(0.0),
                            this.aggrDoubleSum.aggregatedValue());

        this.aggrDoubleSum.aggregateValue(1.1);
        Assert.assertEquals(new DoubleValue(1.1),
                            this.aggrDoubleSum.aggregatedValue());

        this.aggrDoubleSum.aggregateValue(2.3);
        Assert.assertEquals(new DoubleValue(3.4),
                            this.aggrDoubleSum.aggregatedValue());

        this.aggrDoubleSum.aggregateValue(7.0);
        Assert.assertEquals(new DoubleValue(10.4),
                            this.aggrDoubleSum.aggregatedValue());

        // AGGR_DOUBLE_MIN
        this.aggrDoubleMin = context.createAggregator(
                             MockMasterComputation.AGGR_DOUBLE_MIN);

        Assert.assertEquals(new DoubleValue(0.0),
                            this.aggrDoubleMin.aggregatedValue());

        this.aggrDoubleMin.aggregateValue(1.1);
        Assert.assertEquals(new DoubleValue(0.0),
                            this.aggrDoubleMin.aggregatedValue());

        this.aggrDoubleMin.aggregateValue(-10.0);
        Assert.assertEquals(new DoubleValue(-10.0),
                            this.aggrDoubleMin.aggregatedValue());

        this.aggrDoubleMin.aggregateValue(-4.0);
        Assert.assertEquals(new DoubleValue(-10.0),
                            this.aggrDoubleMin.aggregatedValue());
    }