rkhachatryan commented on code in PR #19907:
URL: https://github.com/apache/flink/pull/19907#discussion_r930115553


##########
flink-state-backends/flink-statebackend-changelog/src/main/java/org/apache/flink/state/changelog/ChangelogKeyedStateBackend.java:
##########
@@ -407,8 +408,15 @@ public RunnableFuture<SnapshotResult<KeyedStateHandle>> 
snapshot(
                                         
metrics.reportSnapshotResult(snapshotResult))
                         .thenApply(
                                 snapshotResult ->
-                                        SnapshotResult.of(
-                                                
snapshotResult.getJobManagerOwnedSnapshot())));
+                                        snapshotResult.getTaskLocalSnapshot() 
== null
+                                                        || snapshotResult
+                                                                        
.getJobManagerOwnedSnapshot()
+                                                                == null
+                                                ? SnapshotResult.of(
+                                                        
snapshotResult.getJobManagerOwnedSnapshot())
+                                                : 
SnapshotResult.withLocalState(
+                                                        
snapshotResult.getJobManagerOwnedSnapshot(),
+                                                        
snapshotResult.getTaskLocalSnapshot())));

Review Comment:
   nit: there is no need to re-create the result object, and more importantly 
this is less readable than just casting:
   ```
   .thenApply(this::castSnapshotResult));
   ...
   @SuppressWarnings("unchecked")
   private SnapshotResult<KeyedStateHandle> 
castSnapshotResult(SnapshotResult<?> snapshotResult) {
       return (SnapshotResult<KeyedStateHandle>) snapshotResult;
   }
   
   ```



##########
flink-state-backends/flink-statebackend-changelog/src/main/java/org/apache/flink/state/changelog/ChangelogKeyedStateBackend.java:
##########
@@ -407,8 +408,15 @@ public RunnableFuture<SnapshotResult<KeyedStateHandle>> 
snapshot(
                                         
metrics.reportSnapshotResult(snapshotResult))
                         .thenApply(
                                 snapshotResult ->
-                                        SnapshotResult.of(
-                                                
snapshotResult.getJobManagerOwnedSnapshot())));
+                                        snapshotResult.getTaskLocalSnapshot() 
== null
+                                                        || snapshotResult
+                                                                        
.getJobManagerOwnedSnapshot()
+                                                                == null
+                                                ? SnapshotResult.of(
+                                                        
snapshotResult.getJobManagerOwnedSnapshot())
+                                                : 
SnapshotResult.withLocalState(
+                                                        
snapshotResult.getJobManagerOwnedSnapshot(),
+                                                        
snapshotResult.getTaskLocalSnapshot())));

Review Comment:
   nit: there is no need to re-create the result object, and more importantly 
this is less readable than just casting:
   ```
   .thenApply(this::castSnapshotResult));
   ...
   @SuppressWarnings("unchecked")
   private SnapshotResult<KeyedStateHandle> 
castSnapshotResult(SnapshotResult<?> snapshotResult) {
       return (SnapshotResult<KeyedStateHandle>) snapshotResult;
   }
   
   ```



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