kamalcph commented on code in PR #14116:
URL: https://github.com/apache/kafka/pull/14116#discussion_r1308574000


##########
storage/src/test/java/org/apache/kafka/tiered/storage/actions/CreateTopicAction.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.tiered.storage.actions;
+
+import org.apache.kafka.tiered.storage.TieredStorageTestAction;
+import org.apache.kafka.tiered.storage.TieredStorageTestContext;
+import org.apache.kafka.tiered.storage.specs.TopicSpec;
+import org.apache.kafka.common.config.TopicConfig;
+
+import java.io.PrintStream;
+import java.util.concurrent.ExecutionException;
+
+public final class CreateTopicAction implements TieredStorageTestAction {
+
+    private final TopicSpec spec;
+
+    public CreateTopicAction(TopicSpec spec) {
+        this.spec = spec;
+    }
+
+    @Override
+    public void doExecute(TieredStorageTestContext context) throws 
ExecutionException, InterruptedException {
+        // Ensure offset and time indexes are generated for every record.
+        spec.getProperties().put(TopicConfig.INDEX_INTERVAL_BYTES_CONFIG, "1");
+        // Leverage the use of the segment index size to create a log-segment 
accepting one and only one record.
+        // The minimum size of the indexes is that of an entry, which is 8 for 
the offset index and 12 for the
+        // time index. Hence, since the topic is configured to generate index 
entries for every record with, for
+        // a "small" number of records (i.e. such that the average record size 
times the number of records is
+        // much less than the segment size), the number of records which hold 
in a segment is the multiple of 12
+        // defined below.
+        if (spec.getMaxBatchCountPerSegment() != -1) {
+            spec.getProperties().put(
+                    TopicConfig.SEGMENT_INDEX_BYTES_CONFIG, String.valueOf(12 
* spec.getMaxBatchCountPerSegment()));

Review Comment:
   This is the allocated size for all the indexes. Since, timeIndex requires 12 
bytes for one record batch which is higher than the offsetIndex of 8 bytes.



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