Search in sources :

Example 1 with LegacyKeyedProcessOperator

use of org.apache.flink.streaming.api.operators.LegacyKeyedProcessOperator in project flink by apache.

the class DataStreamTest method testKeyedStreamProcessTranslation.

/**
 * Verify that a {@link KeyedStream#process(ProcessFunction)} call is correctly translated to an
 * operator.
 */
@Test
@Deprecated
public void testKeyedStreamProcessTranslation() {
    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 {
        // Do nothing
        }

        @Override
        public void onTimer(long timestamp, OnTimerContext ctx, Collector<Integer> out) throws Exception {
        // Do nothing
        }
    };
    DataStream<Integer> processed = src.keyBy(new IdentityKeySelector<Long>()).process(processFunction);
    processed.addSink(new DiscardingSink<Integer>());
    assertEquals(processFunction, getFunctionForDataStream(processed));
    assertTrue(getOperatorForDataStream(processed) instanceof LegacyKeyedProcessOperator);
}
Also used : KeyedBroadcastProcessFunction(org.apache.flink.streaming.api.functions.co.KeyedBroadcastProcessFunction) KeyedProcessFunction(org.apache.flink.streaming.api.functions.KeyedProcessFunction) ProcessFunction(org.apache.flink.streaming.api.functions.ProcessFunction) BroadcastProcessFunction(org.apache.flink.streaming.api.functions.co.BroadcastProcessFunction) LegacyKeyedProcessOperator(org.apache.flink.streaming.api.operators.LegacyKeyedProcessOperator) Collector(org.apache.flink.util.Collector) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Test(org.junit.Test)

Aggregations

StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 KeyedProcessFunction (org.apache.flink.streaming.api.functions.KeyedProcessFunction)1 ProcessFunction (org.apache.flink.streaming.api.functions.ProcessFunction)1 BroadcastProcessFunction (org.apache.flink.streaming.api.functions.co.BroadcastProcessFunction)1 KeyedBroadcastProcessFunction (org.apache.flink.streaming.api.functions.co.KeyedBroadcastProcessFunction)1 LegacyKeyedProcessOperator (org.apache.flink.streaming.api.operators.LegacyKeyedProcessOperator)1 Collector (org.apache.flink.util.Collector)1 Test (org.junit.Test)1