Search in sources :

Example 1 with AggregatingProcessingTimeWindowOperator

use of org.apache.flink.streaming.runtime.operators.windowing.AggregatingProcessingTimeWindowOperator in project flink by apache.

the class WindowedStream method createFastTimeOperatorIfValid.

private <R> SingleOutputStreamOperator<R> createFastTimeOperatorIfValid(ReduceFunction<?> function, TypeInformation<R> resultType, String functionName) {
    if (windowAssigner.getClass() == SlidingAlignedProcessingTimeWindows.class && trigger == null && evictor == null) {
        SlidingAlignedProcessingTimeWindows timeWindows = (SlidingAlignedProcessingTimeWindows) windowAssigner;
        final long windowLength = timeWindows.getSize();
        final long windowSlide = timeWindows.getSlide();
        String opName = "Fast " + timeWindows + " of " + functionName;
        @SuppressWarnings("unchecked") ReduceFunction<T> reducer = (ReduceFunction<T>) function;
        @SuppressWarnings("unchecked") OneInputStreamOperator<T, R> op = (OneInputStreamOperator<T, R>) new AggregatingProcessingTimeWindowOperator<>(reducer, input.getKeySelector(), input.getKeyType().createSerializer(getExecutionEnvironment().getConfig()), input.getType().createSerializer(getExecutionEnvironment().getConfig()), windowLength, windowSlide);
        return input.transform(opName, resultType, op);
    } else if (windowAssigner.getClass() == TumblingAlignedProcessingTimeWindows.class && trigger == null && evictor == null) {
        TumblingAlignedProcessingTimeWindows timeWindows = (TumblingAlignedProcessingTimeWindows) windowAssigner;
        final long windowLength = timeWindows.getSize();
        final long windowSlide = timeWindows.getSize();
        String opName = "Fast " + timeWindows + " of " + functionName;
        @SuppressWarnings("unchecked") ReduceFunction<T> reducer = (ReduceFunction<T>) function;
        @SuppressWarnings("unchecked") OneInputStreamOperator<T, R> op = (OneInputStreamOperator<T, R>) new AggregatingProcessingTimeWindowOperator<>(reducer, input.getKeySelector(), input.getKeyType().createSerializer(getExecutionEnvironment().getConfig()), input.getType().createSerializer(getExecutionEnvironment().getConfig()), windowLength, windowSlide);
        return input.transform(opName, resultType, op);
    }
    return null;
}
Also used : ReduceFunction(org.apache.flink.api.common.functions.ReduceFunction) OneInputStreamOperator(org.apache.flink.streaming.api.operators.OneInputStreamOperator) TumblingAlignedProcessingTimeWindows(org.apache.flink.streaming.api.windowing.assigners.TumblingAlignedProcessingTimeWindows) AggregatingProcessingTimeWindowOperator(org.apache.flink.streaming.runtime.operators.windowing.AggregatingProcessingTimeWindowOperator) SlidingAlignedProcessingTimeWindows(org.apache.flink.streaming.api.windowing.assigners.SlidingAlignedProcessingTimeWindows)

Aggregations

ReduceFunction (org.apache.flink.api.common.functions.ReduceFunction)1 OneInputStreamOperator (org.apache.flink.streaming.api.operators.OneInputStreamOperator)1 SlidingAlignedProcessingTimeWindows (org.apache.flink.streaming.api.windowing.assigners.SlidingAlignedProcessingTimeWindows)1 TumblingAlignedProcessingTimeWindows (org.apache.flink.streaming.api.windowing.assigners.TumblingAlignedProcessingTimeWindows)1 AggregatingProcessingTimeWindowOperator (org.apache.flink.streaming.runtime.operators.windowing.AggregatingProcessingTimeWindowOperator)1