mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-19 19:08:02 +08:00
ChunkStreamReader implenents io.ReaderAt
This commit is contained in:
@@ -99,6 +99,7 @@ type ChunkStreamReader struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _ = io.ReadSeeker(&ChunkStreamReader{})
|
var _ = io.ReadSeeker(&ChunkStreamReader{})
|
||||||
|
var _ = io.ReaderAt(&ChunkStreamReader{})
|
||||||
|
|
||||||
func doNewChunkStreamReader(lookupFileIdFn wdclient.LookupFileIdFunctionType, chunks []*filer_pb.FileChunk) *ChunkStreamReader {
|
func doNewChunkStreamReader(lookupFileIdFn wdclient.LookupFileIdFunctionType, chunks []*filer_pb.FileChunk) *ChunkStreamReader {
|
||||||
|
|
||||||
@@ -135,6 +136,14 @@ func NewChunkStreamReader(filerClient filer_pb.FilerClient, chunks []*filer_pb.F
|
|||||||
return doNewChunkStreamReader(lookupFileIdFn, chunks)
|
return doNewChunkStreamReader(lookupFileIdFn, chunks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ChunkStreamReader) ReadAt(p []byte, off int64) (n int, err error) {
|
||||||
|
_, err = c.Seek(off, io.SeekStart)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return c.Read(p)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *ChunkStreamReader) Read(p []byte) (n int, err error) {
|
func (c *ChunkStreamReader) Read(p []byte) (n int, err error) {
|
||||||
for n < len(p) {
|
for n < len(p) {
|
||||||
if c.isBufferEmpty() {
|
if c.isBufferEmpty() {
|
||||||
|
Reference in New Issue
Block a user