masteryhx commented on code in PR #24690:
URL: https://github.com/apache/flink/pull/24690#discussion_r1597852929


##########
flink-runtime/src/main/java/org/apache/flink/runtime/asyncprocessing/AbstractStateIterator.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.runtime.asyncprocessing;
+
+import org.apache.flink.api.common.state.v2.State;
+import org.apache.flink.api.common.state.v2.StateFuture;
+import org.apache.flink.api.common.state.v2.StateIterator;
+import org.apache.flink.core.state.InternalStateFuture;
+import org.apache.flink.core.state.StateFutureUtils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+/**
+ * A {@link StateIterator} implementation to facilitate async data load of 
iterator. Each state
+ * backend could override this class to maintain more variables in need. Any 
subclass should
+ * implement two methods, {@link #hasNext()} and {@link 
#nextPayloadForContinuousLoading()}. The
+ * philosophy behind this class is to carry some already loaded elements and 
provide iterating right
+ * on the task thread, and load following ones if needed (determined by {@link 
#hasNext()}) by
+ * creating **ANOTHER** iterating request. Thus, later it returns another 
iterator instance, and we
+ * continue to apply the user iteration on that instance. The whole elements 
will be iterated by
+ * recursive call of {@code #onNext()}.
+ */
+@SuppressWarnings("rawtypes")
+public abstract class AbstractStateIterator<T> implements StateIterator<T> {
+
+    /** The state this iterator iterates on. */
+    final State originalState;
+
+    /** The request type that create this iterator. */
+    final StateRequestType requestType;
+
+    /** The controller that can receive further requests. */
+    final AsyncExecutionController aec;

Review Comment:
   Could rebase and be `StateRequestHandler`.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to