Package org.dashbuilder.dataset.group

Examples of org.dashbuilder.dataset.group.AggregateFunction


    List listOfNumbers = Arrays.asList(1, 2, 3, 4, 5);
    List listOfStrings = Arrays.asList("A", "B", "C", "A", "B");

    @Test
    public void testSumFunction() throws Exception {
        AggregateFunction sf = aggregateFunctionManager.getFunctionByCode(SumFunction.CODE);
        double result = sf.aggregate(listOfNumbers);
        assertThat(result).isEqualTo(15);
    }
View Full Code Here


        assertThat(result).isEqualTo(15);
    }

    @Test
    public void testAvgFunction() throws Exception {
        AggregateFunction sf = aggregateFunctionManager.getFunctionByCode(AverageFunction.CODE);
        double result = sf.aggregate(listOfNumbers);
        assertThat(result).isEqualTo(3);
    }
View Full Code Here

        assertThat(result).isEqualTo(3);
    }

    @Test
    public void testMaxFunction() throws Exception {
        AggregateFunction sf = aggregateFunctionManager.getFunctionByCode(MaxFunction.CODE);
        double result = sf.aggregate(listOfNumbers);
        assertThat(result).isEqualTo(5);
    }
View Full Code Here

        assertThat(result).isEqualTo(5);
    }

    @Test
    public void testMinFunction() throws Exception {
        AggregateFunction sf = aggregateFunctionManager.getFunctionByCode(MinFunction.CODE);
        double result = sf.aggregate(listOfNumbers);
        assertThat(result).isEqualTo(1);
    }
View Full Code Here

        assertThat(result).isEqualTo(1);
    }

    @Test
    public void testCountFunction() throws Exception {
        AggregateFunction sf = aggregateFunctionManager.getFunctionByCode(CountFunction.CODE);
        double result = sf.aggregate(listOfStrings);
        assertThat(result).isEqualTo(5);
    }
View Full Code Here

        assertThat(result).isEqualTo(5);
    }

    @Test
    public void testDistinctFunction() throws Exception {
        AggregateFunction sf = aggregateFunctionManager.getFunctionByCode(DistinctFunction.CODE);
        double result = sf.aggregate(listOfStrings);
        assertThat(result).isEqualTo(3);
    }
View Full Code Here

                Double sv = index.getAggValue(column.getId(), type);
                if (sv != null) return sv;
            }
            // Do the aggregate calculations.
            chronometer.start();
            AggregateFunction function = aggregateFunctionManager.getFunctionByCode(type.toString().toLowerCase());
            double aggValue = function.aggregate(column.getValues(), index.getRows());
            chronometer.stop();

            // Index the result
            if (index != null) {
                index.indexAggValue(column.getId(), type, aggValue, chronometer.elapsedTime());
View Full Code Here

TOP

Related Classes of org.dashbuilder.dataset.group.AggregateFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.