You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by GitBox <gi...@apache.org> on 2019/08/09 01:40:47 UTC

[GitHub] [samza] Sanil15 commented on a change in pull request #1133: SAMZA-2297: InMemorySystemAdmin offsets are off-by-one in some cases

Sanil15 commented on a change in pull request #1133: SAMZA-2297: InMemorySystemAdmin offsets are off-by-one in some cases 
URL: https://github.com/apache/samza/pull/1133#discussion_r312300765
 
 

 ##########
 File path: samza-core/src/main/java/org/apache/samza/system/inmemory/InMemorySystemConsumer.java
 ##########
 @@ -77,8 +77,19 @@ public void stop() {
    */
   @Override
   public void register(SystemStreamPartition systemStreamPartition, String offset) {
-    LOG.info("Registering ssp {} with starting offset {}", systemStreamPartition, offset);
-    sspToOffset.put(systemStreamPartition, offset);
+    String offsetToRegister;
+    if (offset == null) {
+      LOG.info("Registering ssp {} with starting offset null, overriding to 0", systemStreamPartition);
+      offsetToRegister = "0";
+    } else {
+      LOG.info("Registering ssp {} with starting offset {}", systemStreamPartition, offset);
+      offsetToRegister = offset;
+    }
+    /*
+     * A null offset is the same as the beginning of the stream. Can't use null directly since ConcurrentHashMap doesn't
+     * allow it.
+     */
+    sspToOffset.put(systemStreamPartition, (offset == null) ? "0" : offsetToRegister);
 
 Review comment:
   if, else above already compare for offset == null, why do it again?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services