use of org.apache.flink.streaming.api.operators.KeyedProcessOperator in project flink by apache.
the class DataStreamTest method testKeyedProcessTranslation.
/**
* Verify that a {@link KeyedStream#process(ProcessFunction)} call is correctly translated to
* an operator.
*/
@Test
public void testKeyedProcessTranslation() {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStreamSource<Long> src = env.generateSequence(0, 0);
ProcessFunction<Long, Integer> processFunction = new ProcessFunction<Long, Integer>() {
private static final long serialVersionUID = 1L;
@Override
public void processElement(Long value, Context ctx, Collector<Integer> out) throws Exception {
}
@Override
public void onTimer(long timestamp, OnTimerContext ctx, Collector<Integer> out) throws Exception {
}
};
DataStream<Integer> processed = src.keyBy(new IdentityKeySelector<Long>()).process(processFunction);
processed.addSink(new DiscardingSink<Integer>());
assertEquals(processFunction, getFunctionForDataStream(processed));
assertTrue(getOperatorForDataStream(processed) instanceof KeyedProcessOperator);
}
Aggregations