Search in sources :

Example 26 with ReduceFunction

use of org.apache.flink.api.common.functions.ReduceFunction in project flink by apache.

the class TimestampITCase method testErrorOnEventTimeWithoutTimestamps.

@Test
public void testErrorOnEventTimeWithoutTimestamps() {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.setParallelism(2);
    DataStream<Tuple2<String, Integer>> source1 = env.fromElements(new Tuple2<>("a", 1), new Tuple2<>("b", 2));
    source1.keyBy(0).window(TumblingEventTimeWindows.of(Time.seconds(5))).reduce(new ReduceFunction<Tuple2<String, Integer>>() {

        @Override
        public Tuple2<String, Integer> reduce(Tuple2<String, Integer> value1, Tuple2<String, Integer> value2) {
            return value1;
        }
    }).print();
    try {
        env.execute();
        fail("this should fail with an exception");
    } catch (Exception e) {
    // expected
    }
}
Also used : Tuple2(org.apache.flink.api.java.tuple.Tuple2) ReduceFunction(org.apache.flink.api.common.functions.ReduceFunction) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) CheckpointException(org.apache.flink.runtime.checkpoint.CheckpointException) Test(org.junit.Test)

Aggregations

ReduceFunction (org.apache.flink.api.common.functions.ReduceFunction)26 Test (org.junit.Test)16 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)8 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)8 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)8 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)7 Configuration (org.apache.flink.configuration.Configuration)6 File (java.io.File)5 ListStateDescriptor (org.apache.flink.api.common.state.ListStateDescriptor)5 KryoSerializer (org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer)5 ArrayList (java.util.ArrayList)4 WatermarkStrategy (org.apache.flink.api.common.eventtime.WatermarkStrategy)4 RichReduceFunction (org.apache.flink.api.common.functions.RichReduceFunction)4 TypeSerializer (org.apache.flink.api.common.typeutils.TypeSerializer)4 KeySelector (org.apache.flink.api.java.functions.KeySelector)4 DataStream (org.apache.flink.streaming.api.datastream.DataStream)4 HashMap (java.util.HashMap)3 List (java.util.List)3 TaskInfo (org.apache.flink.api.common.TaskInfo)3 MapStateDescriptor (org.apache.flink.api.common.state.MapStateDescriptor)3