use of org.apache.hyracks.algebricks.runtime.base.IRunningAggregateEvaluatorFactory 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.IRunningAggregateEvaluatorFactory in project asterixdb by apache.
the class RunningAggregatePOperator method contributeRuntimeOperator.
@Override
public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException {
RunningAggregateOperator ragg = (RunningAggregateOperator) op;
List<LogicalVariable> variables = ragg.getVariables();
List<Mutable<ILogicalExpression>> expressions = ragg.getExpressions();
int[] outColumns = new int[variables.size()];
for (int i = 0; i < outColumns.length; i++) {
outColumns[i] = opSchema.findVariable(variables.get(i));
}
IRunningAggregateEvaluatorFactory[] runningAggFuns = new IRunningAggregateEvaluatorFactory[expressions.size()];
IExpressionRuntimeProvider expressionRuntimeProvider = context.getExpressionRuntimeProvider();
for (int i = 0; i < runningAggFuns.length; i++) {
StatefulFunctionCallExpression expr = (StatefulFunctionCallExpression) expressions.get(i).getValue();
runningAggFuns[i] = expressionRuntimeProvider.createRunningAggregateFunctionFactory(expr, context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas, context);
}
// TODO push projections into the operator
int[] projectionList = JobGenHelper.projectAllVariables(opSchema);
RunningAggregateRuntimeFactory runtime = new RunningAggregateRuntimeFactory(outColumns, runningAggFuns, projectionList);
// contribute one Asterix framewriter
RecordDescriptor recDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context);
builder.contributeMicroOperator(ragg, runtime, recDesc);
// and contribute one edge from its child
ILogicalOperator src = ragg.getInputs().get(0).getValue();
builder.contributeGraphEdge(src, 0, ragg, 0);
}
Aggregations