diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-12-07 01:57:55 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-12-07 01:57:55 -0800 |
| commit | 1bfb96f34df19085e99392b4e9af376b617806ad (patch) | |
| tree | dcba98459a8cf484497946b1dea61e3d22116ed3 /weed/filer2/filechunks.go | |
| parent | 29f1673d9766f11b256ca1c0d653aaa7d99e13aa (diff) | |
| download | seaweedfs-1bfb96f34df19085e99392b4e9af376b617806ad.tar.xz seaweedfs-1bfb96f34df19085e99392b4e9af376b617806ad.zip | |
optimization for reading whole chunk with gzip encoding
Diffstat (limited to 'weed/filer2/filechunks.go')
| -rw-r--r-- | weed/filer2/filechunks.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/weed/filer2/filechunks.go b/weed/filer2/filechunks.go index 8f9746324..39e43cf3c 100644 --- a/weed/filer2/filechunks.go +++ b/weed/filer2/filechunks.go @@ -70,6 +70,7 @@ type ChunkView struct { Offset int64 Size uint64 LogicOffset int64 + IsFullChunk bool } func ViewFromChunks(chunks []*filer_pb.FileChunk, offset int64, size int) (views []*ChunkView) { @@ -80,11 +81,13 @@ func ViewFromChunks(chunks []*filer_pb.FileChunk, offset int64, size int) (views for _, chunk := range visibles { if chunk.start <= offset && offset < chunk.stop && offset < stop { + isFullChunk := chunk.isFullChunk && chunk.start == offset && chunk.stop <= stop views = append(views, &ChunkView{ FileId: chunk.fileId, Offset: offset - chunk.start, // offset is the data starting location in this file id Size: uint64(min(chunk.stop, stop) - offset), LogicOffset: offset, + IsFullChunk: isFullChunk, }) offset = min(chunk.stop, stop) } @@ -116,6 +119,7 @@ func mergeIntoVisibles(visibles, newVisibles []*visibleInterval, chunk *filer_pb chunk.Offset+int64(chunk.Size), chunk.FileId, chunk.Mtime, + true, ) length := len(visibles) @@ -135,6 +139,7 @@ func mergeIntoVisibles(visibles, newVisibles []*visibleInterval, chunk *filer_pb chunk.Offset, v.fileId, v.modifiedTime, + false, )) } chunkStop := chunk.Offset + int64(chunk.Size) @@ -144,6 +149,7 @@ func mergeIntoVisibles(visibles, newVisibles []*visibleInterval, chunk *filer_pb v.stop, v.fileId, v.modifiedTime, + false, )) } if chunkStop <= v.start || v.stop <= chunk.Offset { @@ -195,14 +201,16 @@ type visibleInterval struct { stop int64 modifiedTime int64 fileId string + isFullChunk bool } -func newVisibleInterval(start, stop int64, fileId string, modifiedTime int64) *visibleInterval { +func newVisibleInterval(start, stop int64, fileId string, modifiedTime int64, isFullChunk bool) *visibleInterval { return &visibleInterval{ start: start, stop: stop, fileId: fileId, modifiedTime: modifiedTime, + isFullChunk: isFullChunk, } } |
