snuyanzin commented on code in PR #29269:
URL: https://github.com/apache/flink/pull/29269#discussion_r4081526666


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/generated/ProcessTableRunner.java:
##########
@@ -180,41 +162,38 @@ private void processMethod(RunnableWithException method) 
throws Exception {
 
     @SuppressWarnings("unchecked")
     private void moveStateToFunction() throws IOException {
-        Arrays.fill(stateCleared, false);
-        for (int i = 0; i < stateHandles.length; i++) {
-            final State stateHandle = stateHandles[i];
-            if (!(stateHandle instanceof ValueState)) {
+        for (StateHandle stateHandle : stateHandles) {
+            stateHandle.cleared = false;
+            if (stateHandle.kind != StateHandle.Kind.EAGER_VALUE) {
+                // Views access Flink state lazily; nothing to move eagerly.
                 continue;
             }
-            final ValueState<RowData> valueState = (ValueState<RowData>) 
stateHandle;
-            final RowData value = valueState.value();
-            valueStateToFunction[i] = value;
+            final ValueState<RowData> valueState = (ValueState<RowData>) 
stateHandle.state;
+            stateHandle.toFunction = valueState.value();
         }
     }
 
     @SuppressWarnings("unchecked")
     private void moveStateFromFunction() throws IOException {
-        for (int i = 0; i < stateHandles.length; i++) {
-            final State stateHandle = stateHandles[i];
-            if (stateHandle instanceof ValueState) {
-                moveValueStateFromFunction((ValueState<RowData>) stateHandle, 
i);
-            } else {
-                if (stateCleared[i]) {
-                    stateHandle.clear();
-                }
+        for (StateHandle stateHandle : stateHandles) {
+            if (stateHandle.kind == StateHandle.Kind.EAGER_VALUE) {

Review Comment:
   ```suggestion
               if (stateHandle.kind == Kind.EAGER_VALUE) {
   ```
   nit: move import to static?



-- 
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]

Reply via email to