Skip to content

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.

read in case cross chunks

Chris Lu7c10602b49dc
diff --git a/weed/filer2/stream.go b/weed/filer2/stream.go
index bf1b4c24a8..4e785fade4 100644
--- a/weed/filer2/stream.go
+++ b/weed/filer2/stream.go
@@ -98,18 +98,20 @@ func NewChunkStreamReaderFromFiler(masterClient *wdclient.MasterClient, chunks [
}
}
-
func (c *ChunkStreamReader) Read(p []byte) (n int, err error) {
- if c.isBufferEmpty() {
- if c.chunkIndex >= len(c.chunkViews) {
- return 0, io.EOF
+ for n < len(p) {
+ if c.isBufferEmpty() {
+ if c.chunkIndex >= len(c.chunkViews) {
+ return n, io.EOF
+ }
+ chunkView := c.chunkViews[c.chunkIndex]
+ c.fetchChunkToBuffer(chunkView)
+ c.chunkIndex++
}
- chunkView := c.chunkViews[c.chunkIndex]
- c.fetchChunkToBuffer(chunkView)
- c.chunkIndex++
+ t := copy(p[n:], c.buffer[c.bufferPos:])
+ c.bufferPos += t
+ n += t
}
- n = copy(p, c.buffer[c.bufferPos:])
- c.bufferPos += n
return
}