You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2023/01/13 06:37:11 UTC

[GitHub] [kafka] cmccabe commented on a diff in pull request #13108: KAFKA-14618; Fix off by one error in snapshot id

cmccabe commented on code in PR #13108:
URL: https://github.com/apache/kafka/pull/13108#discussion_r1068983515


##########
metadata/src/main/java/org/apache/kafka/image/MetadataProvenance.java:
##########
@@ -28,30 +29,30 @@
 public final class MetadataProvenance {
     public static final MetadataProvenance EMPTY = new MetadataProvenance(-1L, -1, -1L);
 
-    private final long offset;
-    private final int epoch;
+    private final long lastContainedOffset;
+    private final int lastContainedEpoch;
     private final long lastContainedLogTimeMs;
 
     public MetadataProvenance(
-        long offset,
-        int epoch,
+        long lastContainedOffset,
+        int lastContainedEpoch,
         long lastContainedLogTimeMs
     ) {
-        this.offset = offset;
-        this.epoch = epoch;
+        this.lastContainedOffset = lastContainedOffset;
+        this.lastContainedEpoch = lastContainedEpoch;
         this.lastContainedLogTimeMs = lastContainedLogTimeMs;
     }
 
-    public OffsetAndEpoch offsetAndEpoch() {
-        return new OffsetAndEpoch(offset, epoch);
+    public OffsetAndEpoch snapshotId() {
+        return new OffsetAndEpoch(lastContainedOffset + 1, lastContainedEpoch);

Review Comment:
   Can you add a comment about how the snapshot ID contains an offset one greater than the last contained offset? It could otherwise be easy to miss.
   
   Probably include a reference to this JIRA as well.



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

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org