use of org.apache.hyracks.algebricks.runtime.base.IRunningAggregateEvaluator in project asterixdb by apache.
the class TidRunningAggregateDescriptor method createRunningAggregateEvaluatorFactory.
@Override
public IRunningAggregateEvaluatorFactory createRunningAggregateEvaluatorFactory(IScalarEvaluatorFactory[] args) {
return new IRunningAggregateEvaluatorFactory() {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
@Override
public IRunningAggregateEvaluator createRunningAggregateEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
return new IRunningAggregateEvaluator() {
private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
private final ISerializerDeserializer<AInt64> serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);
private final AMutableInt64 m = new AMutableInt64(0);
private int cnt;
@Override
public void step(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
resultStorage.reset();
m.setValue(cnt);
serde.serialize(m, resultStorage.getDataOutput());
result.set(resultStorage);
++cnt;
}
@Override
public void init() throws HyracksDataException {
cnt = 1;
}
};
}
};
}
use of org.apache.hyracks.algebricks.runtime.base.IRunningAggregateEvaluator in project asterixdb by apache.
the class TupleCountRunningAggregateFunctionFactory method createRunningAggregateEvaluator.
@Override
public IRunningAggregateEvaluator createRunningAggregateEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
return new IRunningAggregateEvaluator() {
int cnt;
@Override
public void step(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
try {
++cnt;
abvs.reset();
abvs.getDataOutput().writeInt(cnt);
result.set(abvs);
} catch (IOException e) {
throw new HyracksDataException(e);
}
}
@Override
public void init() throws HyracksDataException {
cnt = 0;
}
};
}
Aggregations