This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new c812c27398 [hotfix] Minor fix for FileIO.listFilesIterative
c812c27398 is described below
commit c812c27398dcd40df88e40ed1d7bca9fa28fb96f
Author: JingsongLi <[email protected]>
AuthorDate: Mon Jan 20 10:31:07 2025 +0800
[hotfix] Minor fix for FileIO.listFilesIterative
---
.../src/main/java/org/apache/paimon/fs/FileIO.java | 18 +++++++++---------
.../main/java/org/apache/paimon/fs/RemoteIterator.java | 7 -------
2 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/paimon-common/src/main/java/org/apache/paimon/fs/FileIO.java
b/paimon-common/src/main/java/org/apache/paimon/fs/FileIO.java
index 5ba16acfca..02f846114e 100644
--- a/paimon-common/src/main/java/org/apache/paimon/fs/FileIO.java
+++ b/paimon-common/src/main/java/org/apache/paimon/fs/FileIO.java
@@ -135,30 +135,30 @@ public interface FileIO extends Serializable {
*/
default RemoteIterator<FileStatus> listFilesIterative(Path path, boolean
recursive)
throws IOException {
+ Queue<FileStatus> files = new LinkedList<>();
+ Queue<Path> directories = new
LinkedList<>(Collections.singletonList(path));
return new RemoteIterator<FileStatus>() {
- private Queue<FileStatus> files = new LinkedList<>();
- private Queue<Path> subdirStack = new
LinkedList<>(Collections.singletonList(path));
@Override
public boolean hasNext() throws IOException {
- maybeUnpackSubdir();
+ maybeUnpackDirectory();
return !files.isEmpty();
}
@Override
public FileStatus next() throws IOException {
- maybeUnpackSubdir();
+ maybeUnpackDirectory();
return files.remove();
}
- private void maybeUnpackSubdir() throws IOException {
+ private void maybeUnpackDirectory() throws IOException {
if (!files.isEmpty()) {
return;
}
- if (subdirStack.isEmpty()) {
+ if (directories.isEmpty()) {
return;
}
- FileStatus[] statuses = listStatus(subdirStack.remove());
+ FileStatus[] statuses = listStatus(directories.remove());
for (FileStatus f : statuses) {
if (!f.isDir()) {
files.add(f);
@@ -167,12 +167,12 @@ public interface FileIO extends Serializable {
if (!recursive) {
continue;
}
- subdirStack.add(f.getPath());
+ directories.add(f.getPath());
}
}
@Override
- public void close() throws IOException {}
+ public void close() {}
};
}
diff --git
a/paimon-common/src/main/java/org/apache/paimon/fs/RemoteIterator.java
b/paimon-common/src/main/java/org/apache/paimon/fs/RemoteIterator.java
index c23de0c199..a2ead7f2bc 100644
--- a/paimon-common/src/main/java/org/apache/paimon/fs/RemoteIterator.java
+++ b/paimon-common/src/main/java/org/apache/paimon/fs/RemoteIterator.java
@@ -39,11 +39,4 @@ public interface RemoteIterator<E> extends Closeable {
* @throws IOException - if failed to list entries lazily
*/
E next() throws IOException;
-
- /**
- * Closes the iterator and its associated resources.
- *
- * @throws IOException - if failed to close the iterator
- */
- void close() throws IOException;
}