chrislu
3 years ago
5 changed files with 66 additions and 7 deletions
-
9weed/filer/filechunk_manifest.go
-
28weed/filer/reader_at.go
-
31weed/filer/reader_pattern.go
-
3weed/filesys/filehandle.go
-
2weed/server/volume_server_handlers_read.go
@ -0,0 +1,31 @@ |
|||
package filer |
|||
|
|||
type ReaderPattern struct { |
|||
isStreaming bool |
|||
lastReadOffset int64 |
|||
} |
|||
|
|||
// For streaming read: only cache the first chunk
|
|||
// For random read: only fetch the requested range, instead of the whole chunk
|
|||
|
|||
func NewReaderPattern() *ReaderPattern { |
|||
return &ReaderPattern{ |
|||
isStreaming: true, |
|||
lastReadOffset: 0, |
|||
} |
|||
} |
|||
|
|||
func (rp *ReaderPattern) MonitorReadAt(offset int64, size int) { |
|||
if rp.lastReadOffset > offset { |
|||
rp.isStreaming = false |
|||
} |
|||
rp.lastReadOffset = offset |
|||
} |
|||
|
|||
func (rp *ReaderPattern) IsStreamingMode() bool { |
|||
return rp.isStreaming |
|||
} |
|||
|
|||
func (rp *ReaderPattern) IsRandomMode() bool { |
|||
return !rp.isStreaming |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue