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
refactor
Chris Luecb234f75aad
diff --git a/weed/filer/stream.go b/weed/filer/stream.goindex 70a278ca57..197b87ab8a 100644--- a/weed/filer/stream.go+++ b/weed/filer/stream.go@@ -89,6 +89,7 @@ func ReadAll(masterClient *wdclient.MasterClient, chunks []*filer_pb.FileChunk)// ---------------- ChunkStreamReader ----------------------------------type ChunkStreamReader struct {chunkViews []*ChunkView+ totalSize int64logicOffset int64buffer []bytebufferOffset int64@@ -107,9 +108,15 @@ func NewChunkStreamReaderFromFiler(masterClient *wdclient.MasterClient, chunks [chunkViews := ViewFromChunks(lookupFileIdFn, chunks, 0, math.MaxInt64)+ var totalSize int64+ for _, chunk := range chunkViews {+ totalSize += int64(chunk.Size)+ }+return &ChunkStreamReader{chunkViews: chunkViews,lookupFileId: lookupFileIdFn,+ totalSize: totalSize,}}@@ -119,9 +126,15 @@ func NewChunkStreamReader(filerClient filer_pb.FilerClient, chunks []*filer_pb.FchunkViews := ViewFromChunks(lookupFileIdFn, chunks, 0, math.MaxInt64)+ var totalSize int64+ for _, chunk := range chunkViews {+ totalSize += int64(chunk.Size)+ }+return &ChunkStreamReader{chunkViews: chunkViews,lookupFileId: lookupFileIdFn,+ totalSize: totalSize,}}@@ -148,20 +161,15 @@ func (c *ChunkStreamReader) isBufferEmpty() bool {func (c *ChunkStreamReader) Seek(offset int64, whence int) (int64, error) {- var totalSize int64- for _, chunk := range c.chunkViews {- totalSize += int64(chunk.Size)- }-var err errorswitch whence {case io.SeekStart:case io.SeekCurrent:offset += c.bufferOffset + int64(c.bufferPos)case io.SeekEnd:- offset = totalSize + offset+ offset = c.totalSize + offset}- if offset > totalSize {+ if offset > c.totalSize {err = io.ErrUnexpectedEOF}