|
40 | 40 | import org.apache.flink.api.java.typeutils.ObjectArrayTypeInfo;
|
41 | 41 | import org.apache.flink.api.java.typeutils.TupleTypeInfo;
|
42 | 42 | import org.apache.flink.api.java.typeutils.TypeExtractor;
|
| 43 | +import org.apache.flink.runtime.asyncprocessing.operators.AbstractAsyncStateUdfStreamOperator; |
| 44 | +import org.apache.flink.runtime.asyncprocessing.operators.AsyncKeyedProcessOperator; |
43 | 45 | import org.apache.flink.streaming.api.datastream.BroadcastConnectedStream;
|
44 | 46 | import org.apache.flink.streaming.api.datastream.BroadcastStream;
|
45 | 47 | import org.apache.flink.streaming.api.datastream.ConnectedStreams;
|
@@ -934,6 +936,48 @@ public void onTimer(long timestamp, OnTimerContext ctx, Collector<Integer> out)
|
934 | 936 | assertThat(getOperatorForDataStream(processed)).isInstanceOf(KeyedProcessOperator.class);
|
935 | 937 | }
|
936 | 938 |
|
| 939 | + /** |
| 940 | + * Verify that a {@link KeyedStream#process(KeyedProcessFunction)} call is correctly translated |
| 941 | + * to an async operator. |
| 942 | + */ |
| 943 | + @Test |
| 944 | + void testAsyncKeyedStreamKeyedProcessTranslation() { |
| 945 | + StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); |
| 946 | + DataStreamSource<Long> src = env.fromSequence(0, 0); |
| 947 | + |
| 948 | + KeyedProcessFunction<Long, Long, Integer> keyedProcessFunction = |
| 949 | + new KeyedProcessFunction<Long, Long, Integer>() { |
| 950 | + private static final long serialVersionUID = 1L; |
| 951 | + |
| 952 | + @Override |
| 953 | + public void processElement(Long value, Context ctx, Collector<Integer> out) |
| 954 | + throws Exception { |
| 955 | + // Do nothing |
| 956 | + } |
| 957 | + |
| 958 | + @Override |
| 959 | + public void onTimer(long timestamp, OnTimerContext ctx, Collector<Integer> out) |
| 960 | + throws Exception { |
| 961 | + // Do nothing |
| 962 | + } |
| 963 | + }; |
| 964 | + |
| 965 | + DataStream<Integer> processed = |
| 966 | + src.keyBy(new IdentityKeySelector<Long>()) |
| 967 | + .enableAsyncState() |
| 968 | + .process(keyedProcessFunction); |
| 969 | + |
| 970 | + processed.sinkTo(new DiscardingSink<Integer>()); |
| 971 | + |
| 972 | + assertThat( |
| 973 | + ((AbstractAsyncStateUdfStreamOperator<?, ?>) |
| 974 | + getOperatorForDataStream(processed)) |
| 975 | + .getUserFunction()) |
| 976 | + .isEqualTo(keyedProcessFunction); |
| 977 | + assertThat(getOperatorForDataStream(processed)) |
| 978 | + .isInstanceOf(AsyncKeyedProcessOperator.class); |
| 979 | + } |
| 980 | + |
937 | 981 | /**
|
938 | 982 | * Verify that a {@link DataStream#process(ProcessFunction)} call is correctly translated to an
|
939 | 983 | * operator.
|
|
0 commit comments