Search in sources :

Example 1 with AllWindowFunction

use of org.apache.flink.streaming.api.functions.windowing.AllWindowFunction in project flink by apache.

the class StateDescriptorPassingTest method testApplyWindowAllState.

@Test
public void testApplyWindowAllState() {
    final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.registerTypeWithKryoSerializer(File.class, JavaSerializer.class);
    // simulate ingestion time
    DataStream<File> src = env.fromElements(new File("/")).assignTimestampsAndWatermarks(WatermarkStrategy.<File>forMonotonousTimestamps().withTimestampAssigner((file, ts) -> System.currentTimeMillis()));
    SingleOutputStreamOperator<?> result = src.windowAll(TumblingEventTimeWindows.of(Time.milliseconds(1000))).apply(new AllWindowFunction<File, String, TimeWindow>() {

        @Override
        public void apply(TimeWindow window, Iterable<File> input, Collector<String> out) {
        }
    });
    validateListStateDescriptorConfigured(result);
}
Also used : Kryo(com.esotericsoftware.kryo.Kryo) Collector(org.apache.flink.util.Collector) TimeWindow(org.apache.flink.streaming.api.windowing.windows.TimeWindow) ProcessAllWindowFunction(org.apache.flink.streaming.api.functions.windowing.ProcessAllWindowFunction) ListStateDescriptor(org.apache.flink.api.common.state.ListStateDescriptor) ReduceFunction(org.apache.flink.api.common.functions.ReduceFunction) JavaSerializer(com.esotericsoftware.kryo.serializers.JavaSerializer) Time(org.apache.flink.streaming.api.windowing.time.Time) TypeSerializer(org.apache.flink.api.common.typeutils.TypeSerializer) KeySelector(org.apache.flink.api.java.functions.KeySelector) StateDescriptor(org.apache.flink.api.common.state.StateDescriptor) KryoSerializer(org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer) SingleOutputStreamOperator(org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator) WindowOperator(org.apache.flink.streaming.runtime.operators.windowing.WindowOperator) Assert.assertTrue(org.junit.Assert.assertTrue) WatermarkStrategy(org.apache.flink.api.common.eventtime.WatermarkStrategy) Test(org.junit.Test) ProcessWindowFunction(org.apache.flink.streaming.api.functions.windowing.ProcessWindowFunction) OneInputTransformation(org.apache.flink.streaming.api.transformations.OneInputTransformation) File(java.io.File) DataStream(org.apache.flink.streaming.api.datastream.DataStream) WindowFunction(org.apache.flink.streaming.api.functions.windowing.WindowFunction) TumblingEventTimeWindows(org.apache.flink.streaming.api.windowing.assigners.TumblingEventTimeWindows) AllWindowFunction(org.apache.flink.streaming.api.functions.windowing.AllWindowFunction) ListSerializer(org.apache.flink.api.common.typeutils.base.ListSerializer) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) File(java.io.File) TimeWindow(org.apache.flink.streaming.api.windowing.windows.TimeWindow) Test(org.junit.Test)

Aggregations

Kryo (com.esotericsoftware.kryo.Kryo)1 JavaSerializer (com.esotericsoftware.kryo.serializers.JavaSerializer)1 File (java.io.File)1 WatermarkStrategy (org.apache.flink.api.common.eventtime.WatermarkStrategy)1 ReduceFunction (org.apache.flink.api.common.functions.ReduceFunction)1 ListStateDescriptor (org.apache.flink.api.common.state.ListStateDescriptor)1 StateDescriptor (org.apache.flink.api.common.state.StateDescriptor)1 TypeSerializer (org.apache.flink.api.common.typeutils.TypeSerializer)1 ListSerializer (org.apache.flink.api.common.typeutils.base.ListSerializer)1 KeySelector (org.apache.flink.api.java.functions.KeySelector)1 KryoSerializer (org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer)1 DataStream (org.apache.flink.streaming.api.datastream.DataStream)1 SingleOutputStreamOperator (org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 AllWindowFunction (org.apache.flink.streaming.api.functions.windowing.AllWindowFunction)1 ProcessAllWindowFunction (org.apache.flink.streaming.api.functions.windowing.ProcessAllWindowFunction)1 ProcessWindowFunction (org.apache.flink.streaming.api.functions.windowing.ProcessWindowFunction)1 WindowFunction (org.apache.flink.streaming.api.functions.windowing.WindowFunction)1 OneInputTransformation (org.apache.flink.streaming.api.transformations.OneInputTransformation)1 TumblingEventTimeWindows (org.apache.flink.streaming.api.windowing.assigners.TumblingEventTimeWindows)1