jsancio commented on code in PR #18391:
URL: https://github.com/apache/kafka/pull/18391#discussion_r2078359476


##########
tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:
##########
@@ -194,9 +195,16 @@ static List<byte[]> readPayloadFile(String 
payloadFilePath, String payloadDelimi
                 throw new IllegalArgumentException("File does not exist or 
empty file provided.");
             }
 
-            String[] payloadList = 
Files.readString(path).split(payloadDelimiter);
+            List<String> payloadList = new ArrayList<>();
+            try (Scanner payLoadScanner = new Scanner(path, 
StandardCharsets.UTF_8)) {
+                //setting the delimiter while parsing the file, avoids loading 
entire data in memory before split
+                payLoadScanner.useDelimiter(payloadDelimiter);

Review Comment:
   Right. But I need to make sure that the new implement 
(`Scanner#useDelimiter`) generates the same payloads as the old implementation 
(`String#split`).
   
   From what I can tell they both use the same regex implementation and pattern 
matcher so they should split the file content in a similar fashion.



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