qinjunjerry commented on a change in pull request #13309:
URL: https://github.com/apache/flink/pull/13309#discussion_r482788381



##########
File path: 
flink-libraries/flink-state-processing-api/src/main/java/org/apache/flink/state/api/functions/StatePathExtractor.java
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.state.api.functions;
+
+import org.apache.flink.api.common.functions.FlatMapFunction;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.runtime.checkpoint.OperatorState;
+import org.apache.flink.runtime.checkpoint.OperatorSubtaskState;
+import org.apache.flink.runtime.state.KeyGroupsStateHandle;
+import org.apache.flink.runtime.state.KeyedStateHandle;
+import org.apache.flink.runtime.state.OperatorStateHandle;
+import org.apache.flink.runtime.state.StreamStateHandle;
+import org.apache.flink.runtime.state.filesystem.FileStateHandle;
+import org.apache.flink.util.Collector;
+
+/**
+ * Extract from an OperatorState a set of state file paths.
+ */
+public class StatePathExtractor implements FlatMapFunction<OperatorState, 
String> {
+       /**
+        * This method recursively looks for the contained {@link 
FileStateHandle}s in a given {@link StreamStateHandle}.
+        *
+        * @param handle the {@code StreamStateHandle} to check for a contained 
{@code FileStateHandle}
+        * @return the file path if the given {@code StreamStateHandle} 
contains a {@code FileStateHandle} object, null
+        * otherwise
+        */
+       private Path getStateFilePathFromStreamStateHandle(StreamStateHandle 
handle) {
+               if (handle instanceof FileStateHandle) {
+                       return ((FileStateHandle) handle).getFilePath();
+               } else if (handle instanceof OperatorStateHandle) {
+                       return getStateFilePathFromStreamStateHandle(
+                               ((OperatorStateHandle) 
handle).getDelegateStateHandle()
+                       );
+               } else if (handle instanceof KeyedStateHandle) {
+                       if (handle instanceof KeyGroupsStateHandle) {

Review comment:
       The other StateHandle which could contain `FileStateHandle` is 
`IncrementalKeyedStateHandle`. I did not consider that since currently 
state-processor-api supports savepoint only.  Will add a comment there. Thanks.




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

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


Reply via email to