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;
}
Aggregations