diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-05-24 01:22:37 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-05-24 01:22:37 -0700 |
| commit | d773e11c7a65903b3ee1adea801a20f91cb0c7aa (patch) | |
| tree | 9e40f834e929d826c9ce5dacd9fa57ca0de57bc6 /weed/filer2/filechunks.go | |
| parent | 00d0274fd7c829f5d26c051f5832e0f602929b08 (diff) | |
| download | seaweedfs-d773e11c7a65903b3ee1adea801a20f91cb0c7aa.tar.xz seaweedfs-d773e11c7a65903b3ee1adea801a20f91cb0c7aa.zip | |
file handler directly read from volume servers
this mostly works fine now!
next: need to cache files to local disk
Diffstat (limited to 'weed/filer2/filechunks.go')
| -rw-r--r-- | weed/filer2/filechunks.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/weed/filer2/filechunks.go b/weed/filer2/filechunks.go index 93cee81de..6bdfbd48e 100644 --- a/weed/filer2/filechunks.go +++ b/weed/filer2/filechunks.go @@ -52,7 +52,14 @@ func FindUnusedFileChunks(oldChunks, newChunks []*filer_pb.FileChunk) (unused [] return } -func ReadFromChunks(chunks []*filer_pb.FileChunk, offset int64, size int) (views []*filer_pb.FileChunk) { +type ChunkView struct { + FileId string + Offset int64 + Size uint64 + LogicOffset int64 +} + +func ReadFromChunks(chunks []*filer_pb.FileChunk, offset int64, size int) (views []*ChunkView) { visibles := nonOverlappingVisibleIntervals(chunks) @@ -60,10 +67,11 @@ func ReadFromChunks(chunks []*filer_pb.FileChunk, offset int64, size int) (views for _, chunk := range visibles { if chunk.start <= offset && offset < chunk.stop { - views = append(views, &filer_pb.FileChunk{ - FileId: chunk.fileId, - Offset: offset - chunk.start, // offset is the data starting location in this file id - Size: uint64(min(chunk.stop, stop) - offset), + 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, }) offset = min(chunk.stop, stop) } |
