smdsbz commented on code in PR #4834: URL: https://github.com/apache/paimon/pull/4834#discussion_r1914251102
########## paimon-common/src/main/java/org/apache/paimon/fs/FileIO.java: ########## @@ -104,6 +107,71 @@ public interface FileIO extends Serializable { */ FileStatus[] listStatus(Path path) throws IOException; + /** + * List the statuses of the files in the given path if the path is a directory. + * + * @param path given path + * @param recursive if set to <code>true</code> will recursively list files in sub-directories, + * otherwise only files in the current directory will be listed + * @return the statuses of the files in the given path + */ + default FileStatus[] listFiles(Path path, boolean recursive) throws IOException { + List<FileStatus> statuses = new ArrayList<>(); + FileStatus[] outer = listStatus(path); + if (outer != null) { + for (FileStatus f : outer) { + if (!f.isDir()) { + statuses.add(f); + continue; + } + if (!recursive) { + continue; + } + FileStatus[] inner = listFiles(f.getPath(), true); + statuses.addAll(Arrays.asList(inner)); + } + } + return statuses.toArray(new FileStatus[0]); + } + + /** + * List the statuses of the files in the given path in non-overlapping pages, if the path is a + * directory. + * + * @param path given path + * @param recursive if set to <code>true</code> will recursively list files in subdirectories, + * otherwise only files in the current directory will be listed + * @param pageSize maximum size of the page + * @param continuationToken If supplied will list files after this token, otherwise list from + * the beginning. You may acquire this token from the return of this method. + * @return A page of statuses of the files in the given path and the continuation token of this + * page. The continuation token will be <code>null</code> if the returned page is the last + * page. + */ + default Pair<FileStatus[], String> listFilesPaged( + Path path, boolean recursive, long pageSize, @Nullable String continuationToken) + throws IOException { + FileStatus[] all = listFiles(path, recursive); Review Comment: Also adding `supportsListFilesPaged` for testing the availability of `listFilesPaged`. -- 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: issues-unsubscr...@paimon.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org