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 09:53:42 UTC

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

Hisoka-X commented on code in PR #3038:
URL: https://github.com/apache/incubator-seatunnel/pull/3038#discussion_r991088239


##########
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:
   Why we should skip some char?



##########
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);
+            long lineNumber = lineNumberReader.getLineNumber();
+            return lineNumber + 1;

Review Comment:
   Why should +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