tzulitai commented on a change in pull request #8565: [FLINK-11947] Support 
MapState value schema evolution for RocksDB
URL: https://github.com/apache/flink/pull/8565#discussion_r289758725
 
 

 ##########
 File path: 
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBMapState.java
 ##########
 @@ -202,6 +205,32 @@ public UV next() {
                };
        }
 
+       @Override
+       public void migrateSerializedValue(
+               DataInputDeserializer serializedOldValueInput,
+               DataOutputSerializer serializedMigratedValueOutput,
+               TypeSerializer<Map<UK, UV>> priorSerializer,
+               TypeSerializer<Map<UK, UV>> newSerializer) throws 
StateMigrationException {
+
+               checkArgument(priorSerializer instanceof MapSerializer);
+               checkArgument(newSerializer instanceof MapSerializer);
+
+               TypeSerializer<UV> priorMapValueSerializer = 
((MapSerializer<UK, UV>) priorSerializer).getValueSerializer();
+               TypeSerializer<UV> newMapValueSerializer = ((MapSerializer<UK, 
UV>) newSerializer).getValueSerializer();
+
+               try {
+                       boolean isNull = serializedOldValueInput.readBoolean();
+                       UV mapUserValue = null;
+                       if (!isNull) {
+                               mapUserValue = 
priorMapValueSerializer.deserialize(serializedOldValueInput);
+                       }
+                       serializedMigratedValueOutput.writeBoolean(mapUserValue 
== null);
+                       newMapValueSerializer.serialize(mapUserValue, 
serializedMigratedValueOutput);
 
 Review comment:
   Should we still be serializing if `mapUserValue == null`? That seems a bit 
odd to me.

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


With regards,
Apache Git Services

Reply via email to