mumrah commented on code in PR #14047:
URL: https://github.com/apache/kafka/pull/14047#discussion_r1269713183


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/RecordHelpers.java:
##########
@@ -467,6 +471,72 @@ public static Record newEmptyGroupMetadataRecord(
         );
     }
 
+    /**
+     * Creates an OffsetCommit record.
+     *
+     * @param groupId           The group id.
+     * @param topic             The topic name.
+     * @param partitionId       The partition id.
+     * @param offsetAndMetadata The offset and metadata.
+     * @param metadataVersion   The metadata version.
+     * @return The record.
+     */
+    public static Record newOffsetCommitRecord(
+        String groupId,
+        String topic,
+        int partitionId,
+        OffsetAndMetadata offsetAndMetadata,
+        MetadataVersion metadataVersion
+    ) {
+        short version = offsetAndMetadata.expireTimestampMs.isPresent() ?
+            (short) 1 : metadataVersion.offsetCommitValueVersion();
+
+        return new Record(
+            new ApiMessageAndVersion(
+                new OffsetCommitKey()
+                    .setGroup(groupId)
+                    .setTopic(topic)
+                    .setPartition(partitionId),
+                (short) 1

Review Comment:
   Can we define these `(short) 1` as a constant? That might reduce the changes 
of us changing one without the others in the future



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/RecordHelpers.java:
##########
@@ -467,6 +471,72 @@ public static Record newEmptyGroupMetadataRecord(
         );
     }
 
+    /**
+     * Creates an OffsetCommit record.
+     *
+     * @param groupId           The group id.
+     * @param topic             The topic name.
+     * @param partitionId       The partition id.
+     * @param offsetAndMetadata The offset and metadata.
+     * @param metadataVersion   The metadata version.
+     * @return The record.
+     */
+    public static Record newOffsetCommitRecord(
+        String groupId,
+        String topic,
+        int partitionId,
+        OffsetAndMetadata offsetAndMetadata,
+        MetadataVersion metadataVersion
+    ) {
+        short version = offsetAndMetadata.expireTimestampMs.isPresent() ?
+            (short) 1 : metadataVersion.offsetCommitValueVersion();

Review Comment:
   Would it make sense to relocate this logic and the linked logic into 
MetadataVersion?



-- 
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-unsubscr...@kafka.apache.org

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

Reply via email to