Search in sources :

Example 11 with Window

use of org.apache.flink.streaming.api.windowing.windows.Window in project flink by apache.

the class GroupedProcessingTimeWindowExample method main.

public static void main(String[] args) throws Exception {
    final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    DataStream<Tuple2<Long, Long>> stream = env.addSource(new DataSource());
    stream.keyBy(value -> value.f0).window(SlidingProcessingTimeWindows.of(Time.milliseconds(2500), Time.milliseconds(500))).reduce(new SummingReducer()).addSink(new DiscardingSink<>());
    env.execute();
}
Also used : Tuple(org.apache.flink.api.java.tuple.Tuple) SlidingProcessingTimeWindows(org.apache.flink.streaming.api.windowing.assigners.SlidingProcessingTimeWindows) Time(org.apache.flink.streaming.api.windowing.time.Time) KeySelector(org.apache.flink.api.java.functions.KeySelector) Tuple2(org.apache.flink.api.java.tuple.Tuple2) DiscardingSink(org.apache.flink.streaming.api.functions.sink.DiscardingSink) Window(org.apache.flink.streaming.api.windowing.windows.Window) DataStream(org.apache.flink.streaming.api.datastream.DataStream) WindowFunction(org.apache.flink.streaming.api.functions.windowing.WindowFunction) Collector(org.apache.flink.util.Collector) RichParallelSourceFunction(org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction) ReduceFunction(org.apache.flink.api.common.functions.ReduceFunction) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Tuple2(org.apache.flink.api.java.tuple.Tuple2) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)

Aggregations

ReduceFunction (org.apache.flink.api.common.functions.ReduceFunction)11 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)11 DiscardingSink (org.apache.flink.streaming.api.functions.sink.DiscardingSink)11 WindowFunction (org.apache.flink.streaming.api.functions.windowing.WindowFunction)11 Time (org.apache.flink.streaming.api.windowing.time.Time)11 Window (org.apache.flink.streaming.api.windowing.windows.Window)11 Collector (org.apache.flink.util.Collector)11 List (java.util.List)10 WatermarkStrategy (org.apache.flink.api.common.eventtime.WatermarkStrategy)10 ReducingState (org.apache.flink.api.common.state.ReducingState)10 ReducingStateDescriptor (org.apache.flink.api.common.state.ReducingStateDescriptor)10 Types (org.apache.flink.api.common.typeinfo.Types)10 LongSerializer (org.apache.flink.api.common.typeutils.base.LongSerializer)10 StateBackend (org.apache.flink.runtime.state.StateBackend)10 WindowReaderFunction (org.apache.flink.state.api.functions.WindowReaderFunction)10 AggregateSum (org.apache.flink.state.api.utils.AggregateSum)10 ReduceSum (org.apache.flink.state.api.utils.ReduceSum)10 SavepointTestBase (org.apache.flink.state.api.utils.SavepointTestBase)10 ProcessWindowFunction (org.apache.flink.streaming.api.functions.windowing.ProcessWindowFunction)10 GlobalWindows (org.apache.flink.streaming.api.windowing.assigners.GlobalWindows)10