qinjunjerry commented on a change in pull request #13309:
URL: https://github.com/apache/flink/pull/13309#discussion_r482453649
##########
File path:
flink-libraries/flink-state-processing-api/src/main/java/org/apache/flink/state/api/WritableSavepoint.java
##########
@@ -88,40 +106,119 @@ public final void write(String path) {
List<BootstrapTransformationWithID<?>>
newOperatorTransformations = metadata.getNewOperators();
DataSet<OperatorState> newOperatorStates =
writeOperatorStates(newOperatorTransformations, savepointPath);
- List<OperatorState> existingOperators =
metadata.getExistingOperators();
+ List<OperatorState> existingOperatorStateList =
metadata.getExistingOperators();
- DataSet<OperatorState> finalOperatorStates =
unionOperatorStates(newOperatorStates, existingOperators);
+ DataSet<OperatorState> finalOperatorStates;
+ if (existingOperatorStateList.isEmpty()) {
+ finalOperatorStates = newOperatorStates;
+ } else {
+ DataSet<OperatorState> existingOperatorStates =
newOperatorStates.getExecutionEnvironment()
+ .fromCollection(existingOperatorStateList);
+
+ existingOperatorStates
+ .map(new OperatorState2PathSetMapFunction())
+ .flatMap(new
FlatMapFunction<Set<Optional<Path>>, Optional<Path>>() {
+ @Override
+ public void flatMap(Set<Optional<Path>>
value, Collector<Optional<Path>> out) throws Exception {
+ for (Optional<Path> path :
value) {
+ out.collect(path);
+ }
+ }
+ })
+ .filter(Optional<Path>::isPresent)
+ .map(Optional<Path>::get)
+ .returns(TypeInformation.of(new
TypeHint<Path>(){}))
Review comment:
Indeed.
----------------------------------------------------------------
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:
[email protected]