You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ij...@apache.org on 2017/11/23 14:37:22 UTC

kafka git commit: MINOR: Remove unnecessary batch iteration in FileRecords.downConvert

Repository: kafka
Updated Branches:
  refs/heads/trunk 67ba4c4ea -> 90da94c38


MINOR: Remove unnecessary batch iteration in FileRecords.downConvert

Author: Ismael Juma <is...@juma.me.uk>

Reviewers: Rajini Sivaram <ra...@googlemail.com>

Closes #4192 from ijuma/avoid-unnecessary-batch-iteration-in-down-convert


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/90da94c3
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/90da94c3
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/90da94c3

Branch: refs/heads/trunk
Commit: 90da94c3848531e638f31231ea3068fabf4cc8dd
Parents: 67ba4c4
Author: Ismael Juma <is...@juma.me.uk>
Authored: Thu Nov 23 14:37:07 2017 +0000
Committer: Ismael Juma <is...@juma.me.uk>
Committed: Thu Nov 23 14:37:07 2017 +0000

----------------------------------------------------------------------
 .../main/java/org/apache/kafka/common/record/FileRecords.java | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/90da94c3/clients/src/main/java/org/apache/kafka/common/record/FileRecords.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/common/record/FileRecords.java b/clients/src/main/java/org/apache/kafka/common/record/FileRecords.java
index e907abc..36591a0 100644
--- a/clients/src/main/java/org/apache/kafka/common/record/FileRecords.java
+++ b/clients/src/main/java/org/apache/kafka/common/record/FileRecords.java
@@ -31,7 +31,6 @@ import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.channels.GatheringByteChannel;
 import java.util.Iterator;
-import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
@@ -237,8 +236,8 @@ public class FileRecords extends AbstractRecords implements Closeable {
 
     @Override
     public ConvertedRecords<? extends Records> downConvert(byte toMagic, long firstOffset, Time time) {
-        List<? extends RecordBatch> batches = Utils.toList(batches().iterator());
-        if (batches.isEmpty()) {
+        ConvertedRecords<MemoryRecords> convertedRecords = downConvert(batches, toMagic, firstOffset, time);
+        if (convertedRecords.recordsProcessingStats().numRecordsConverted() == 0) {
             // This indicates that the message is too large, which means that the buffer is not large
             // enough to hold a full record batch. We just return all the bytes in this instance.
             // Even though the record batch does not have the right format version, we expect old clients
@@ -248,7 +247,7 @@ public class FileRecords extends AbstractRecords implements Closeable {
             // one full record batch, even if it requires exceeding the max fetch size requested by the client.
             return new ConvertedRecords<>(this, RecordsProcessingStats.EMPTY);
         } else {
-            return downConvert(batches, toMagic, firstOffset, time);
+            return convertedRecords;
         }
     }