SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
Java: add SeaweedInputStream example
Chris Lu502554887f58
diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedInputStream.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedInputStream.javaindex 312e77aa23..519ff0fd99 100644--- a/other/java/client/src/main/java/seaweedfs/client/SeaweedInputStream.java+++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedInputStream.java@@ -26,6 +26,21 @@ public class SeaweedInputStream extends InputStream {private boolean closed = false;+ public SeaweedInputStream(+ final FilerGrpcClient filerGrpcClient,+ final String dir, final String name) throws IOException {+ this.filerGrpcClient = filerGrpcClient;+ this.path = dir;+ FilerClient filerClient = new FilerClient(filerGrpcClient);+ this.entry = filerClient.lookupEntry(dir, name);+ this.contentLength = SeaweedRead.fileSize(entry);++ this.visibleIntervalList = SeaweedRead.nonOverlappingVisibleIntervals(filerGrpcClient, entry.getChunksList());++ LOG.debug("new path:{} entry:{} visibleIntervalList:{}", path, entry, visibleIntervalList);++ }+public SeaweedInputStream(final FilerGrpcClient filerGrpcClient,final String path,diff --git a/other/java/examples/src/main/java/com/seaweedfs/examples/UnzipFile.java b/other/java/examples/src/main/java/com/seaweedfs/examples/UnzipFile.javaindex 317327be44..fad1471b69 100644--- a/other/java/examples/src/main/java/com/seaweedfs/examples/UnzipFile.java+++ b/other/java/examples/src/main/java/com/seaweedfs/examples/UnzipFile.java@@ -1,8 +1,7 @@package com.seaweedfs.examples;-import seaweed.hdfs.SeaweedHadoopInputStream;-import seaweedfs.client.FilerClient;import seaweedfs.client.FilerGrpcClient;+import seaweedfs.client.SeaweedInputStream;import java.io.FileInputStream;import java.io.IOException;@@ -15,7 +14,6 @@ public class UnzipFile {public static void main(String[] args) throws IOException {FilerGrpcClient filerGrpcClient = new FilerGrpcClient("localhost", 18888);- FilerClient filerClient = new FilerClient(filerGrpcClient);long startTime = System.currentTimeMillis();parseZip("/Users/chris/tmp/test.zip");@@ -24,12 +22,8 @@ public class UnzipFile {long localProcessTime = startTime2 - startTime;- SeaweedHadoopInputStream seaweedInputStream = new SeaweedHadoopInputStream(- filerGrpcClient,- new org.apache.hadoop.fs.FileSystem.Statistics(""),- "/",- filerClient.lookupEntry("/", "test.zip")- );+ SeaweedInputStream seaweedInputStream = new SeaweedInputStream(+ filerGrpcClient, "/", "test.zip");parseZip(seaweedInputStream);long swProcessTime = System.currentTimeMillis() - startTime2;