Examples of AggregateFunction


Examples of com.inadco.hbl.api.AggregateFunction

                               Aggregation.Builder accumulator,
                               Aggregation source,
                               SliceOperation operation) {

        for (String funcName : funcNames) {
            AggregateFunction func = functions.get(funcName);
            if (func == null)
                throw new UnsupportedOperationException(String.format("Unsupported aggregate function:\"%s\".",
                                                                      funcName));
            func.merge(accumulator, source, operation);
        }

    }
View Full Code Here

Examples of com.inadco.hbl.api.AggregateFunction

    public Object getAggregate(String measure, String functionName) throws HblException {
        try {
            Integer index = measureName2IndexMap.get(measure);
            if (index == null)
                throw new HblException(String.format("Invalid measure name:%s.", measure));
            AggregateFunction af = afr.findFunction(functionName);
            if (af == null)
                throw new HblException(String.format("Invalid function name:%s.", functionName));
            if (result == null)
                throw new HblException("no current result");
            Aggregation measureAggr = result[index];
            if (measureAggr == null) {
                Aggregation.Builder b = delegate.current().getMeasures()[index];
                result[index] = b == null ? null : (measureAggr = b.build()); // cache
            }

            return af.getAggrValue(measureAggr);
        } catch (IOException exc) {
            throw new HblException(exc.getMessage(), exc);
        }

    }
View Full Code Here

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

Examples of org.dashbuilder.dataset.group.AggregateFunction

        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

Examples of org.dashbuilder.dataset.group.AggregateFunction

        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

Examples of org.dashbuilder.dataset.group.AggregateFunction

        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

Examples of org.dashbuilder.dataset.group.AggregateFunction

        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

Examples of org.dashbuilder.dataset.group.AggregateFunction

        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

Examples of org.dashbuilder.dataset.group.AggregateFunction

                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

Examples of org.eclipse.persistence.jpa.jpql.parser.AggregateFunction

    if (stateObject.isDecorated()) {
      toText(stateObject);
    }
    else {
      AggregateFunction expression = stateObject.getExpression();

      // Identifier
      appendIdentifier((expression != null) ? expression.getActualIdentifier() : stateObject.getIdentifier(), stateObject.getIdentifier());

      // '('
      if (shouldOutput(expression) || expression.hasLeftParenthesis()) {
        writer.append(formatIdentifier(LEFT_PARENTHESIS));
      }

      // 'DISTINCT'
      if (stateObject.hasDistinct()) {
        appendIdentifier((expression != null) ? expression.getActualDistinctIdentifier() : DISTINCT, DISTINCT);

        if (shouldOutput(expression) || expression.hasSpaceAfterDistinct()) {
          writer.append(SPACE);
        }
      }

      // Encapsulated expression
      if (stateObject.hasStateObject()) {
        stateObject.getStateObject().accept(this);
      }

      // ')'
      if (shouldOutput(expression) || expression.hasRightParenthesis()) {
        writer.append(formatIdentifier(RIGHT_PARENTHESIS));
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.