apoorvmittal10 commented on code in PR #16263:
URL: https://github.com/apache/kafka/pull/16263#discussion_r1638478747


##########
server/src/main/java/org/apache/kafka/server/share/CachedSharePartition.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.share;
+
+import java.util.Objects;
+import java.util.Optional;
+import org.apache.kafka.common.TopicIdPartition;
+import org.apache.kafka.common.Uuid;
+import org.apache.kafka.common.message.ShareFetchResponseData;
+import org.apache.kafka.common.protocol.Errors;
+import org.apache.kafka.common.requests.ShareFetchRequest;
+import org.apache.kafka.common.requests.ShareFetchResponse;
+import org.apache.kafka.common.utils.ImplicitLinkedHashCollection;
+
+/**
+ * A cached share partition. The broker maintains a set of these objects for 
each share session.
+ * <p>
+ * We store many of these objects, so it is important for them to be 
memory-efficient.
+ * That is why we store topic and partition separately rather than storing a 
TopicPartition
+ * object. The TP object takes up more memory because it is a separate JVM 
object, and
+ * because it stores the cached hash code in memory.
+ */
+public class CachedSharePartition implements 
ImplicitLinkedHashCollection.Element {
+
+    private final String topic;
+    private final Uuid topicId;
+    private final int partition;
+    private final Optional<Integer> leaderEpoch;
+    private int maxBytes;
+    private boolean requiresUpdateInResponse;
+
+    private int cachedNext = ImplicitLinkedHashCollection.INVALID_INDEX;
+    private int cachedPrev = ImplicitLinkedHashCollection.INVALID_INDEX;
+
+    private CachedSharePartition(String topic, Uuid topicId, int partition, 
int maxBytes, Optional<Integer> leaderEpoch,
+                                 boolean requiresUpdateInResponse) {
+        this.topic = topic;

Review Comment:
   This is not needed then: 
https://github.com/apache/kafka/pull/16263#discussion_r1638435378



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