mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-23 07:33:34 +08:00
since we already know the chunk size, no need to iterate
This commit is contained in:
@@ -46,10 +46,12 @@ func (c *ChunkCache) GetChunk(fileId string, chunkSize uint64) (data []byte) {
|
|||||||
|
|
||||||
func (c *ChunkCache) doGetChunk(fileId string, chunkSize uint64) (data []byte) {
|
func (c *ChunkCache) doGetChunk(fileId string, chunkSize uint64) (data []byte) {
|
||||||
|
|
||||||
|
if chunkSize < memCacheSizeLimit {
|
||||||
data = c.memCache.GetChunk(fileId)
|
data = c.memCache.GetChunk(fileId)
|
||||||
if len(data) != 0 && len(data) >= int(chunkSize) {
|
if len(data) >= int(chunkSize) {
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fid, err := needle.ParseFileIdFromString(fileId)
|
fid, err := needle.ParseFileIdFromString(fileId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -57,9 +59,21 @@ func (c *ChunkCache) doGetChunk(fileId string, chunkSize uint64) (data []byte) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, diskCache := range c.diskCaches {
|
if chunkSize < onDiskCacheSizeLimit0 {
|
||||||
data := diskCache.getChunk(fid.Key)
|
data = c.diskCaches[0].getChunk(fid.Key)
|
||||||
if len(data) != 0 && len(data) >= int(chunkSize) {
|
if len(data) >= int(chunkSize) {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if chunkSize < onDiskCacheSizeLimit1 {
|
||||||
|
data = c.diskCaches[1].getChunk(fid.Key)
|
||||||
|
if len(data) >= int(chunkSize) {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
data = c.diskCaches[2].getChunk(fid.Key)
|
||||||
|
if len(data) >= int(chunkSize) {
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user