use of org.apache.flink.streaming.api.functions.co.CoFlatMapFunction in project flink by apache.
the class DataStreamTest method testNaming.
/**
* Tests {@link SingleOutputStreamOperator#name(String)} functionality.
*
* @throws Exception
*/
@Test
public void testNaming() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream<Long> dataStream1 = env.generateSequence(0, 0).name("testSource1").map(new MapFunction<Long, Long>() {
@Override
public Long map(Long value) throws Exception {
return null;
}
}).name("testMap");
DataStream<Long> dataStream2 = env.generateSequence(0, 0).name("testSource2").map(new MapFunction<Long, Long>() {
@Override
public Long map(Long value) throws Exception {
return null;
}
}).name("testMap");
dataStream1.connect(dataStream2).flatMap(new CoFlatMapFunction<Long, Long, Long>() {
@Override
public void flatMap1(Long value, Collector<Long> out) throws Exception {
}
@Override
public void flatMap2(Long value, Collector<Long> out) throws Exception {
}
}).name("testCoFlatMap").windowAll(GlobalWindows.create()).trigger(PurgingTrigger.of(CountTrigger.of(10))).fold(0L, new FoldFunction<Long, Long>() {
private static final long serialVersionUID = 1L;
@Override
public Long fold(Long accumulator, Long value) throws Exception {
return null;
}
}).name("testWindowFold").print();
//test functionality through the operator names in the execution plan
String plan = env.getExecutionPlan();
assertTrue(plan.contains("testSource1"));
assertTrue(plan.contains("testSource2"));
assertTrue(plan.contains("testMap"));
assertTrue(plan.contains("testMap"));
assertTrue(plan.contains("testCoFlatMap"));
assertTrue(plan.contains("testWindowFold"));
}
Aggregations