Search in sources :

Example 6 with IAggregateEvaluatorFactory

use of org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory in project asterixdb by apache.

the class EmptyStreamAggregateDescriptor method createAggregateEvaluatorFactory.

@Override
public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(IScalarEvaluatorFactory[] args) {
    return new IAggregateEvaluatorFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
            return new IAggregateEvaluator() {

                private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();

                @SuppressWarnings("rawtypes")
                private ISerializerDeserializer serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ABOOLEAN);

                boolean res = true;

                @Override
                public void init() throws HyracksDataException {
                    res = true;
                }

                @Override
                public void step(IFrameTupleReference tuple) throws HyracksDataException {
                    res = false;
                }

                @SuppressWarnings("unchecked")
                @Override
                public void finish(IPointable result) throws HyracksDataException {
                    resultStorage.reset();
                    ABoolean b = res ? ABoolean.TRUE : ABoolean.FALSE;
                    serde.serialize(b, resultStorage.getDataOutput());
                    result.set(resultStorage);
                }

                @Override
                public void finishPartial(IPointable result) throws HyracksDataException {
                    finish(result);
                }
            };
        }
    };
}
Also used : ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) ABoolean(org.apache.asterix.om.base.ABoolean) IFrameTupleReference(org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference) IAggregateEvaluator(org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator) IPointable(org.apache.hyracks.data.std.api.IPointable) IAggregateEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)

Aggregations

IAggregateEvaluatorFactory (org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory)6 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)3 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)3 IHyracksTaskContext (org.apache.hyracks.api.context.IHyracksTaskContext)3 RecordDescriptor (org.apache.hyracks.api.dataflow.value.RecordDescriptor)3 ABoolean (org.apache.asterix.om.base.ABoolean)2 Mutable (org.apache.commons.lang3.mutable.Mutable)2 AggregateFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression)2 IExpressionRuntimeProvider (org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionRuntimeProvider)2 AggregateOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator)2 IAggregateEvaluator (org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator)2 SimpleAlgebricksAccumulatingAggregatorFactory (org.apache.hyracks.algebricks.runtime.operators.aggreg.SimpleAlgebricksAccumulatingAggregatorFactory)2 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)2 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)2 IOperatorDescriptorRegistry (org.apache.hyracks.api.job.IOperatorDescriptorRegistry)2 IPointable (org.apache.hyracks.data.std.api.IPointable)2 ArrayBackedValueStorage (org.apache.hyracks.data.std.util.ArrayBackedValueStorage)2 IFrameTupleReference (org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference)2 IAggregatorDescriptorFactory (org.apache.hyracks.dataflow.std.group.IAggregatorDescriptorFactory)2 ArrayList (java.util.ArrayList)1