junrao commented on code in PR #19661:
URL: https://github.com/apache/kafka/pull/19661#discussion_r2082571937


##########
clients/src/main/java/org/apache/kafka/common/record/FileRecords.java:
##########
@@ -54,33 +54,55 @@ public class FileRecords extends AbstractRecords implements 
Closeable {
      * The {@code FileRecords.open} methods should be used instead of this 
constructor whenever possible.
      * The constructor is visible for tests.
      */
-    FileRecords(File file,
-                FileChannel channel,
-                int start,
-                int end,
-                boolean isSlice) throws IOException {
+    FileRecords(
+        File file,
+        FileChannel channel,
+        int end
+    ) throws IOException {
         this.file = file;
         this.channel = channel;
-        this.start = start;
+        this.start = 0;
         this.end = end;
-        this.isSlice = isSlice;
+        this.isSlice = false;
         this.size = new AtomicInteger();
 
-        if (isSlice) {
-            // don't check the file size if this is just a slice view
-            size.set(end - start);
-        } else {
-            if (channel.size() > Integer.MAX_VALUE)
-                throw new KafkaException("The size of segment " + file + " (" 
+ channel.size() +
-                        ") is larger than the maximum allowed segment size of 
" + Integer.MAX_VALUE);
+        if (channel.size() > Integer.MAX_VALUE) {
+            throw new KafkaException(
+                "The size of segment " + file + " (" + channel.size() +
+                ") is larger than the maximum allowed segment size of " + 
Integer.MAX_VALUE
+            );
+        }
 
-            int limit = Math.min((int) channel.size(), end);
-            size.set(limit - start);
+        int limit = Math.min((int) channel.size(), end);
+        size.set(limit - start);
 
-            // if this is not a slice, update the file pointer to the end of 
the file
-            // set the file position to the last byte in the file
-            channel.position(limit);
-        }
+        // if this is not a slice, update the file pointer to the end of the 
file

Review Comment:
   Should we change this comment since this constructor is not for slicing?



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