Read from the disks in parallel during object read

This commit is contained in:
Krishna Srinivas 2015-07-28 17:52:24 +05:30
parent 55d22fa8d6
commit e1280779ed

View File

@ -543,13 +543,25 @@ func (b bucket) decodeEncodedData(totalLeft, blockSize int64, readers map[int]io
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
encodedBytes := make([][]byte, encoder.k+encoder.m) encodedBytes := make([][]byte, encoder.k+encoder.m)
errCh := make(chan error)
var errRet error
for i, reader := range readers { for i, reader := range readers {
var bytesBuffer bytes.Buffer go func(i int, reader io.Reader) {
_, err := io.CopyN(&bytesBuffer, reader, int64(curChunkSize)) encodedBytes[i] = make([]byte, curChunkSize)
if err != nil { _, err := io.ReadFull(reader, encodedBytes[i])
return nil, iodine.New(err, nil) errCh <- err
}(i, reader)
} }
encodedBytes[i] = bytesBuffer.Bytes() for range readers {
err := <-errCh
if err != nil {
errRet = err
}
}
if errRet != nil {
return nil, iodine.New(errRet, nil)
} }
decodedData, err := encoder.Decode(encodedBytes, int(curBlockSize)) decodedData, err := encoder.Decode(encodedBytes, int(curBlockSize))
if err != nil { if err != nil {