xinyuiscool commented on a change in pull request #14802:
URL: https://github.com/apache/beam/pull/14802#discussion_r633903148



##########
File path: 
runners/samza/src/main/java/org/apache/beam/runners/samza/runtime/SamzaTimerInternalsFactory.java
##########
@@ -702,8 +673,14 @@ public void encode(TimerKey<K> value, OutputStream 
outStream)
       if (keyCoder != null) {
         key = keyCoder.decode(inStream);
       }
+      
timerKeyBuilder.setTimerId(timerId).setStateNamespace(namespace).setKey(key);
+
+      // check if the stream has more available bytes. This is to ensure 
backward compatibility with
+      // old rocksdb state which does not encode timer family data
+      final String timerFamilyId = inStream.available() > 0 ? 
STRING_CODER.decode(inStream) : "";
+      timerKeyBuilder.setTimerFamilyId(timerFamilyId);
 
-      return new TimerKey<>(key, namespace, timerId);
+      return timerKeyBuilder.build();

Review comment:
       RIght, it seems nicer to have the builder in the end instead of cutting 
it in half. 




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


Reply via email to