diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-11-30 04:34:04 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-11-30 04:34:04 -0800 |
| commit | f4abd01adf9fb2ebdefa844b2a4f0aaf8eeb1ccc (patch) | |
| tree | 87406670846a99820d7b6bb37dc3d2cf9362a9de /other/java/hdfs3/src/main | |
| parent | a9c6be5fc3fffad6403ce63aa3951121491eb1d1 (diff) | |
| download | seaweedfs-f4abd01adf9fb2ebdefa844b2a4f0aaf8eeb1ccc.tar.xz seaweedfs-f4abd01adf9fb2ebdefa844b2a4f0aaf8eeb1ccc.zip | |
filer: cache small file to filer store
Diffstat (limited to 'other/java/hdfs3/src/main')
| -rw-r--r-- | other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java | 1 | ||||
| -rw-r--r-- | other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedInputStream.java | 8 |
2 files changed, 8 insertions, 1 deletions
diff --git a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java index 1ad809f9a..2ef1a7468 100644 --- a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java +++ b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java @@ -193,6 +193,7 @@ public class SeaweedFileSystemStore { if (existingEntry != null) { entry = FilerProto.Entry.newBuilder(); entry.mergeFrom(existingEntry); + entry.clearContent(); entry.getAttributesBuilder().setMtime(now); LOG.debug("createFile merged entry path:{} entry:{} from:{}", path, entry, existingEntry); writePosition = SeaweedRead.fileSize(existingEntry); diff --git a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedInputStream.java b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedInputStream.java index 8bda2e092..8e406206d 100644 --- a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedInputStream.java +++ b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedInputStream.java @@ -84,7 +84,13 @@ public class SeaweedInputStream extends FSInputStream { throw new IllegalArgumentException("requested read length is more than will fit after requested offset in buffer"); } - long bytesRead = SeaweedRead.read(this.filerGrpcClient, this.visibleIntervalList, this.position, b, off, len, SeaweedRead.fileSize(entry)); + long bytesRead = 0; + if (position+len < entry.getContent().size()) { + entry.getContent().copyTo(b, (int) position, (int) off, len); + } else { + bytesRead = SeaweedRead.read(this.filerGrpcClient, this.visibleIntervalList, this.position, b, off, len, SeaweedRead.fileSize(entry)); + } + if (bytesRead > Integer.MAX_VALUE) { throw new IOException("Unexpected Content-Length"); } |
