aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-02-27 03:57:24 -0800
committerchrislu <chris.lu@gmail.com>2022-02-27 03:57:24 -0800
commit941ced60a46a447b98918ff488946a201b0e05b9 (patch)
tree38836175cfeb41c975007834b7ec270fbe9678ff
parentf9d9eed0c9458db0ea3bdd707747e06570e3eabf (diff)
downloadseaweedfs-941ced60a46a447b98918ff488946a201b0e05b9.tar.xz
seaweedfs-941ced60a46a447b98918ff488946a201b0e05b9.zip
download 2 chunks if at the beginning of a file
-rw-r--r--weed/filer/reader_at.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/weed/filer/reader_at.go b/weed/filer/reader_at.go
index 8ee627a21..18015e0b3 100644
--- a/weed/filer/reader_at.go
+++ b/weed/filer/reader_at.go
@@ -168,10 +168,16 @@ func (c *ChunkReadAt) readChunkSliceAt(buffer []byte, chunkView *ChunkView, next
}
n, err = c.readerCache.ReadChunkAt(buffer, chunkView.FileId, chunkView.CipherKey, chunkView.IsGzipped, int64(offset), int(chunkView.ChunkSize), chunkView.LogicOffset == 0)
- if c.lastChunkFid != "" && c.lastChunkFid != chunkView.FileId {
+ if c.lastChunkFid != chunkView.FileId {
if chunkView.Offset == 0 { // start of a new chunk
- c.readerCache.UnCache(c.lastChunkFid)
- c.readerCache.MaybeCache(nextChunkViews)
+ if c.lastChunkFid != "" {
+ c.readerCache.UnCache(c.lastChunkFid)
+ c.readerCache.MaybeCache(nextChunkViews)
+ } else {
+ if len(nextChunkViews) >= 1 {
+ c.readerCache.MaybeCache(nextChunkViews[:1]) // just read the next chunk if at the very beginning
+ }
+ }
}
}
c.lastChunkFid = chunkView.FileId