StefanRRichter commented on a change in pull request #6875: [FLINK-9808] [state
backends] Migrate state when necessary in state backends
URL: https://github.com/apache/flink/pull/6875#discussion_r226684033
##########
File path:
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/AbstractRocksDBState.java
##########
@@ -154,6 +159,29 @@ public void setCurrentNamespace(N namespace) {
return backend.db.get(columnFamily,
tmpKeySerializationView.getCopyOfBuffer());
}
+ public byte[] migrateSerializedValue(
+ byte[] serializedOldValue,
+ TypeSerializer<V> priorSerializer,
+ TypeSerializer<V> newSerializer) throws
StateMigrationException {
+
+ try {
+ V value = priorSerializer.deserialize(new
DataInputViewStreamWrapper(new ByteArrayInputStream(serializedOldValue)));
+
+ ByteArrayOutputStream baos = new
ByteArrayOutputStream();
+ DataOutputViewStreamWrapper out = new
DataOutputViewStreamWrapper(baos);
Review comment:
This method is called in a loop. You should avoid creating streams and other
temporary objects on each invocation. Instead, let the calling loop pass them
in and reuse the same instances for the whole process. If we had a
`StateValueTransformer` instance, they could also hold them as members.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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