Zakelly commented on code in PR #25717: URL: https://github.com/apache/flink/pull/25717#discussion_r1903721138
########## flink-runtime/src/main/java/org/apache/flink/streaming/api/operators/asyncprocessing/AsyncStateKeyedProcessOperator.java: ########## @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.streaming.api.operators.asyncprocessing; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.runtime.asyncprocessing.operators.AbstractAsyncStateUdfStreamOperator; +import org.apache.flink.runtime.state.VoidNamespace; +import org.apache.flink.runtime.state.VoidNamespaceSerializer; +import org.apache.flink.streaming.api.SimpleTimerService; +import org.apache.flink.streaming.api.TimeDomain; +import org.apache.flink.streaming.api.TimerService; +import org.apache.flink.streaming.api.functions.KeyedProcessFunction; +import org.apache.flink.streaming.api.operators.InternalTimer; +import org.apache.flink.streaming.api.operators.InternalTimerService; +import org.apache.flink.streaming.api.operators.KeyedProcessOperator; +import org.apache.flink.streaming.api.operators.OneInputStreamOperator; +import org.apache.flink.streaming.api.operators.StreamOperator; +import org.apache.flink.streaming.api.operators.TimestampedCollector; +import org.apache.flink.streaming.api.operators.Triggerable; +import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; +import org.apache.flink.util.OutputTag; + +import static org.apache.flink.util.Preconditions.checkNotNull; +import static org.apache.flink.util.Preconditions.checkState; + +/** + * A {@link StreamOperator} for executing {@link KeyedProcessFunction KeyedProcessFunctions}. + * + * <p>This class is nearly identical with {@link KeyedProcessOperator}, but extending from {@link + * AbstractAsyncStateUdfStreamOperator} to integrate with asynchronous state access. Another + * difference is this class is internal. + */ +@Internal +public class AsyncStateKeyedProcessOperator<K, IN, OUT> + extends AbstractAsyncStateUdfStreamOperator<OUT, KeyedProcessFunction<K, IN, OUT>> + implements OneInputStreamOperator<IN, OUT>, Triggerable<K, VoidNamespace> { + + private static final long serialVersionUID = 1L; + + private transient TimestampedCollector<OUT> collector; + + private transient ContextImpl context; + + private transient OnTimerContextImpl onTimerContext; + + public AsyncStateKeyedProcessOperator(KeyedProcessFunction<K, IN, OUT> function) { + super(function); + } + + @Override + public void open() throws Exception { + super.open(); + collector = new TimestampedCollector<>(output); Review Comment: The timestamp is set before the actual processing, which may involves several async procedure. In the meantime, other record may reset the timestamp, resulting in previous record may produce downstream event with wrong timestamp. I have implement a class `TimestampedCollectorWithDeclaredVariable` to keep the timestamp alongwith record context. The timestamp is independent between records. Please use `AsyncKeyedProcessOperator` instead. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
