You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/10/10 10:39:51 UTC

[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #3038: [E2E][ST-Engine] Add test data consistency in 3 node cluster and fix bug

EricJoy2048 commented on code in PR #3038:
URL: https://github.com/apache/incubator-seatunnel/pull/3038#discussion_r991146012


##########
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:
##########
@@ -80,4 +84,77 @@ public static void createNewFile(String filePath) {
             createParentFile(file);
         }
     }
+
+    /**
+     * return the line number of file
+     *
+     * @param filePath The file need be read
+     * @return
+     */
+    public static Long getFileLineNumber(@NonNull String filePath) {
+        try (LineNumberReader lineNumberReader = new LineNumberReader(new FileReader(filePath))) {
+            lineNumberReader.skip(Long.MAX_VALUE);

Review Comment:
   > 
   
   I will use replace LineNumberReader, because if the file content chars more than Long.MAX_VALUE, it will error.
   
   ```
   try {
           return Files.lines(Paths.get(filePath)).count();
       } catch (IOException e) {
           return -1;
       }
   ```
   



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org