m1a2st commented on code in PR #20346: URL: https://github.com/apache/kafka/pull/20346#discussion_r2276512958
########## metadata/src/main/java/org/apache/kafka/image/MetadataProvenance.java: ########## @@ -20,51 +20,22 @@ import org.apache.kafka.server.common.OffsetAndEpoch; import org.apache.kafka.snapshot.Snapshots; -import java.util.Objects; - /** * Information about the source of a metadata image. */ -public final class MetadataProvenance { +public record MetadataProvenance(long lastContainedOffset, int lastContainedEpoch, long lastContainedLogTimeMs, + boolean isOffsetBatchAligned) { public static final MetadataProvenance EMPTY = new MetadataProvenance(-1L, -1, -1L, false); - private final long lastContainedOffset; - private final int lastContainedEpoch; - private final long lastContainedLogTimeMs; - private final boolean isOffsetBatchAligned; - - public MetadataProvenance( - long lastContainedOffset, - int lastContainedEpoch, - long lastContainedLogTimeMs, - boolean isOffsetBatchAligned - ) { - this.lastContainedOffset = lastContainedOffset; - this.lastContainedEpoch = lastContainedEpoch; - this.lastContainedLogTimeMs = lastContainedLogTimeMs; - this.isOffsetBatchAligned = isOffsetBatchAligned; - } - public OffsetAndEpoch snapshotId() { return new OffsetAndEpoch(lastContainedOffset + 1, lastContainedEpoch); } - public long lastContainedOffset() { - return lastContainedOffset; - } - - public int lastContainedEpoch() { - return lastContainedEpoch; - } - - public long lastContainedLogTimeMs() { - return lastContainedLogTimeMs; - } - /** * Returns whether lastContainedOffset is the last offset in a record batch */ + @Override public boolean isOffsetBatchAligned() { return isOffsetBatchAligned; } Review Comment: This overridden method can also be removed. ########## metadata/src/main/java/org/apache/kafka/metadata/placement/TopicAssignment.java: ########## @@ -18,42 +18,22 @@ package org.apache.kafka.metadata.placement; import java.util.List; -import java.util.Objects; /** * The topic assignment. - * + * <p> * This class is immutable. It's internal state does not change. */ -public class TopicAssignment { - private final List<PartitionAssignment> assignments; - +public record TopicAssignment(List<PartitionAssignment> assignments) { public TopicAssignment(List<PartitionAssignment> assignments) { this.assignments = List.copyOf(assignments); } /** * @return The replica assignment for each partition, where the index in the list corresponds to different partition. */ + @Override public List<PartitionAssignment> assignments() { return assignments; } Review Comment: ditto -- 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