use of org.ballerinalang.siddhi.query.api.expression.Expression in project ballerina by ballerina-lang.
the class AvgIncrementalAttributeAggregator method getBaseAggregators.
@Override
public Expression[] getBaseAggregators() {
Expression sumAggregator = Expression.function("sum", Expression.variable(getBaseAttributes()[0].getName()));
Expression countAggregator = Expression.function("sum", Expression.variable(getBaseAttributes()[1].getName()));
return new Expression[] { sumAggregator, countAggregator };
}
use of org.ballerinalang.siddhi.query.api.expression.Expression in project ballerina by ballerina-lang.
the class CountIncrementalAttributeAggregator method init.
@Override
public void init(String attributeName, Attribute.Type attributeType) {
Attribute count;
Expression countInitialValue;
// Since we set the initial value of count, we can simply set it as long
// However, since count is summed internally (in avg incremental calculation),
// ensure that either double or long is used here (since return value of sum is long or
// double. Long is chosen here)
count = new Attribute("AGG_COUNT", Attribute.Type.LONG);
countInitialValue = Expression.value(1L);
this.baseAttributes = new Attribute[] { count };
this.baseAttributesInitialValues = new Expression[] { countInitialValue };
assert baseAttributes.length == baseAttributesInitialValues.length;
}
Aggregations