mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
ChunkStreamReader implenents io.ReaderAt
This commit is contained in:
parent
59732a0529
commit
de730b079d
|
@ -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() {
|
||||||
|
|
Loading…
Reference in a new issue