Package com.facebook.presto.operator.aggregation.state

Examples of com.facebook.presto.operator.aggregation.state.StateCompiler


        this.finalType = checkNotNull(finalType, "final type is null");
        this.intermediateType = checkNotNull(intermediateType, "intermediate type is null");
        this.parameterTypes = ImmutableList.of(checkNotNull(parameterType, "parameter type is null"));
        java.lang.reflect.Type[] types = TypeParameterUtils.getTypeParameters(AbstractAggregationFunction.class, getClass());
        checkState(types.length == 1 && types[0] instanceof Class);
        stateFactory = new StateCompiler().generateStateFactory((Class<T>) types[0]);
        stateSerializer = new StateCompiler().generateStateSerializer((Class<T>) types[0]);
        this.approximationSupported = approximationSupported;
    }
View Full Code Here


    protected AbstractApproximateAggregationFunction(Type finalType, Type intermediateType, Type parameterType)
    {
        super(finalType, intermediateType, parameterType);
        java.lang.reflect.Type[] types = TypeParameterUtils.getTypeParameters(AbstractApproximateAggregationFunction.class, getClass());
        checkState(types.length == 1 && types[0] instanceof Class);
        stateFactory = new StateCompiler().generateStateFactory((Class<T>) types[0]);
        stateSerializer = new StateCompiler().generateStateSerializer((Class<T>) types[0]);
    }
View Full Code Here

    protected AbstractAggregationFunction(Type finalType, Type intermediateType, Type parameterType)
    {
        super(finalType, intermediateType, parameterType);
        java.lang.reflect.Type[] types = TypeParameterUtils.getTypeParameters(AbstractAggregationFunction.class, getClass());
        checkState(types.length == 1 && types[0] instanceof Class);
        stateFactory = new StateCompiler().generateStateFactory((Class<T>) types[0]);
        stateSerializer = new StateCompiler().generateStateSerializer((Class<T>) types[0]);
    }
View Full Code Here

        DynamicClassLoader classLoader = new DynamicClassLoader(clazz.getClassLoader());

        ImmutableList.Builder<InternalAggregationFunction> builder = ImmutableList.builder();
        for (Class<?> stateClass : getStateClasses(clazz)) {
            AccumulatorStateSerializer<?> stateSerializer = new StateCompiler().generateStateSerializer(stateClass, classLoader);
            Type intermediateType = stateSerializer.getSerializedType();
            Method intermediateInputFunction = getIntermediateInputFunction(clazz, stateClass);
            Method combineFunction = getCombineFunction(clazz, stateClass);
            AccumulatorStateFactory<?> stateFactory = new StateCompiler().generateStateFactory(stateClass, classLoader);

            for (Method outputFunction : getOutputFunctions(clazz, stateClass)) {
                for (Method inputFunction : getInputFunctions(clazz, stateClass)) {
                    for (String name : getNames(outputFunction, aggregationAnnotation)) {
                        List<Type> inputTypes = getInputTypes(inputFunction);
View Full Code Here

public class TestStateCompiler
{
    @Test
    public void testPrimitiveNullableLongSerialization()
    {
        StateCompiler compiler = new StateCompiler();

        AccumulatorStateFactory<NullableBigintState> factory = compiler.generateStateFactory(NullableBigintState.class);
        AccumulatorStateSerializer<NullableBigintState> serializer = compiler.generateStateSerializer(NullableBigintState.class);
        NullableBigintState state = factory.createSingleState();
        NullableBigintState deserializedState = factory.createSingleState();

        state.setLong(2);
        state.setNull(false);
View Full Code Here

    }

    @Test
    public void testPrimitiveLongSerialization()
    {
        StateCompiler compiler = new StateCompiler();

        AccumulatorStateFactory<LongState> factory = compiler.generateStateFactory(LongState.class);
        AccumulatorStateSerializer<LongState> serializer = compiler.generateStateSerializer(LongState.class);
        LongState state = factory.createSingleState();
        LongState deserializedState = factory.createSingleState();

        state.setLong(2);
View Full Code Here

    }

    @Test
    public void testGetSerializedType()
    {
        StateCompiler compiler = new StateCompiler();
        AccumulatorStateSerializer<LongState> serializer = compiler.generateStateSerializer(LongState.class);
        assertEquals(serializer.getSerializedType(), BigintType.BIGINT);
    }
View Full Code Here

    }

    @Test
    public void testPrimitiveBooleanSerialization()
    {
        StateCompiler compiler = new StateCompiler();

        AccumulatorStateFactory<BooleanState> factory = compiler.generateStateFactory(BooleanState.class);
        AccumulatorStateSerializer<BooleanState> serializer = compiler.generateStateSerializer(BooleanState.class);
        BooleanState state = factory.createSingleState();
        BooleanState deserializedState = factory.createSingleState();

        state.setBoolean(true);
View Full Code Here

    }

    @Test
    public void testPrimitiveByteSerialization()
    {
        StateCompiler compiler = new StateCompiler();

        AccumulatorStateFactory<ByteState> factory = compiler.generateStateFactory(ByteState.class);
        AccumulatorStateSerializer<ByteState> serializer = compiler.generateStateSerializer(ByteState.class);
        ByteState state = factory.createSingleState();
        ByteState deserializedState = factory.createSingleState();

        state.setByte((byte) 3);
View Full Code Here

    }

    @Test
    public void testVarianceStateSerialization()
    {
        StateCompiler compiler = new StateCompiler();

        AccumulatorStateFactory<VarianceState> factory = compiler.generateStateFactory(VarianceState.class);
        AccumulatorStateSerializer<VarianceState> serializer = compiler.generateStateSerializer(VarianceState.class);
        VarianceState singleState = factory.createSingleState();
        VarianceState deserializedState = factory.createSingleState();

        singleState.setMean(1);
        singleState.setCount(2);
View Full Code Here

TOP

Related Classes of com.facebook.presto.operator.aggregation.state.StateCompiler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.