diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-12-17 01:25:02 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-12-17 01:25:02 -0800 |
| commit | d11cfdb356d93e1d0dfba739dee9458a43b67e19 (patch) | |
| tree | d68a38828199649a4c7508cde604614c19e639fd /other/java/client | |
| parent | 52712782a215d2e4eebcc8de07dde2b08f7c61c1 (diff) | |
| download | seaweedfs-d11cfdb356d93e1d0dfba739dee9458a43b67e19.tar.xz seaweedfs-d11cfdb356d93e1d0dfba739dee9458a43b67e19.zip | |
paginate through large folders
Diffstat (limited to 'other/java/client')
| -rw-r--r-- | other/java/client/pom.xml | 2 | ||||
| -rw-r--r-- | other/java/client/src/main/java/seaweedfs/client/FilerClient.java | 19 |
2 files changed, 19 insertions, 2 deletions
diff --git a/other/java/client/pom.xml b/other/java/client/pom.xml index a3c56856e..808abb98d 100644 --- a/other/java/client/pom.xml +++ b/other/java/client/pom.xml @@ -4,7 +4,7 @@ <groupId>com.github.chrislusf</groupId> <artifactId>seaweedfs-client</artifactId> - <version>1.0.2</version> + <version>1.0.3</version> <parent> <groupId>org.sonatype.oss</groupId> diff --git a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java index 8414ee303..ff84b053f 100644 --- a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java +++ b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java @@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -137,7 +138,23 @@ public class FilerClient { } public List<FilerProto.Entry> listEntries(String path) { - return listEntries(path, "", "", 100000); + List<FilerProto.Entry> results = new ArrayList<FilerProto.Entry>(); + String lastFileName = ""; + for (int limit = Integer.MAX_VALUE; limit > 0; ) { + List<FilerProto.Entry> t = listEntries(path, "", lastFileName, 1024); + if (t == null) { + break; + } + int nSize = t.size(); + if (nSize > 0) { + limit -= nSize; + lastFileName = t.get(nSize - 1).getName(); + } + if (t.size() < 1024) { + break; + } + } + return results; } public List<FilerProto.Entry> listEntries(String path, String entryPrefix, String lastEntryName, int limit) { |
