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



##########
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:
       nit: we do not need to declare the builder at the begining
   
   we can do 
   
   ```
   return TimerKey.builder().setX().setY().setZ().build();
   ```

##########
File path: 
runners/samza/src/main/java/org/apache/beam/runners/samza/runtime/SamzaTimerInternalsFactory.java
##########
@@ -682,16 +650,19 @@ public void encode(TimerKey<K> value, OutputStream 
outStream)
         throws CoderException, IOException {
 
       // encode the timestamp first
-      STRING_CODER.encode(value.timerId, outStream);
-      STRING_CODER.encode(value.stateNamespace.stringKey(), outStream);
+      STRING_CODER.encode(value.getTimerId(), outStream);
+      STRING_CODER.encode(value.getStateNamespace().stringKey(), outStream);
 
       if (keyCoder != null) {
-        keyCoder.encode(value.key, outStream);
+        keyCoder.encode(value.getKey(), outStream);
       }
+
+      STRING_CODER.encode(value.getTimerFamilyId(), outStream);

Review comment:
       I guess the answer is Yes but just to double check whether we want to 
encode it if timer family id is an empty string.




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