ijuma commented on code in PR #13043: URL: https://github.com/apache/kafka/pull/13043#discussion_r1063722024
########## storage/src/main/java/org/apache/kafka/server/log/internals/ProducerStateEntry.java: ########## @@ -0,0 +1,143 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.kafka.server.log.internals; + +import org.apache.kafka.common.record.RecordBatch; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.OptionalLong; +import java.util.stream.Stream; + +/** + * The batchMetadata is ordered such that the batch with the lowest sequence is at the head of the queue while the + * batch with the highest sequence is at the tail of the queue. We will retain at most {@link ProducerStateEntry#NUM_BATCHES_TO_RETAIN} + * elements in the queue. When the queue is at capacity, we remove the first element to make space for the incoming batch. + */ +public class ProducerStateEntry { + public static final int NUM_BATCHES_TO_RETAIN = 5; + public final long producerId; + private final List<BatchMetadata> batchMetadata; + private short producerEpoch; + public int coordinatorEpoch; + public long lastTimestamp; + public OptionalLong currentTxnFirstOffset; + + public ProducerStateEntry(long producerId) { + this(producerId, new ArrayList<>(), RecordBatch.NO_PRODUCER_EPOCH, -1, RecordBatch.NO_TIMESTAMP, OptionalLong.empty()); + } Review Comment: Got it. Was the previous approach clearer perhaps? That is, we could have a static factory method called `empty` to distinguish between the `empty` versus `non-empty` case. -- 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