Skip to content

Commit

Permalink
paginate through large folders
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislusf committed Dec 17, 2018
1 parent 5271278 commit d11cfdb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion other/java/client/pom.xml
Expand Up @@ -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>
Expand Down
Expand Up @@ -5,6 +5,7 @@

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -137,7 +138,23 @@ public FilerProto.Entry.Builder newFileEntry(String name, int mode,
}

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) {
Expand Down
13 changes: 7 additions & 6 deletions other/java/hdfs/pom.xml
Expand Up @@ -4,9 +4,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<properties>
<seaweedfs.client.version>1.0.3</seaweedfs.client.version>
<hadoop.version>3.1.1</hadoop.version>
</properties>

<groupId>com.github.chrislusf</groupId>
<artifactId>seaweedfs-hadoop-client</artifactId>
<version>1.0.2</version>
<version>${seaweedfs.client.version}</version>

<parent>
<groupId>org.sonatype.oss</groupId>
Expand Down Expand Up @@ -133,10 +138,6 @@
</plugins>
</build>

<properties>
<hadoop.version>3.1.1</hadoop.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
Expand All @@ -146,7 +147,7 @@
<dependency>
<groupId>com.github.chrislusf</groupId>
<artifactId>seaweedfs-client</artifactId>
<version>1.0.2</version>
<version>${seaweedfs.client.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
Expand Down
Expand Up @@ -310,9 +310,6 @@ public boolean truncate(Path f, long newLength) throws IOException {
getClass().getSimpleName() + " FileSystem implementation");
}

/**
* See {@link FileContext#createSymlink(Path, Path, boolean)}.
*/
@Override
public void createSymlink(final Path target, final Path link,
final boolean createParent) throws AccessControlException,
Expand All @@ -324,10 +321,6 @@ public void createSymlink(final Path target, final Path link,
"Filesystem does not support symlinks!");
}

/**
* See {@link AbstractFileSystem#supportsSymlinks()}.
*/
@Override
public boolean supportsSymlinks() {
return false;
}
Expand Down

0 comments on commit d11cfdb

Please sign in to comment.