Search in sources :

Example 1 with Calculation

use of org.opennms.newts.api.query.Calculation in project newts by OpenNMS.

the class Compute method next.

@Override
public Row<Measurement> next() {
    if (!hasNext())
        throw new NoSuchElementException();
    Row<Measurement> row = m_input.next();
    for (Calculation calc : m_resultDescriptor.getCalculations().values()) {
        double v = calc.getCalculationFunction().apply(getValues(row, calc.getArgs()));
        row.addElement(new Measurement(row.getTimestamp(), row.getResource(), calc.getLabel(), v));
    }
    return row;
}
Also used : Measurement(org.opennms.newts.api.Measurement) Calculation(org.opennms.newts.api.query.Calculation) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

NoSuchElementException (java.util.NoSuchElementException)1 Measurement (org.opennms.newts.api.Measurement)1 Calculation (org.opennms.newts.api.query.Calculation)1