Parallel upload to block blob support
This commit is contained in:
Родитель
559751a9a8
Коммит
f5afd62008
|
@ -107,13 +107,7 @@ func UploadBufferToBlockBlob(ctx context.Context, b []byte,
|
||||||
}
|
}
|
||||||
|
|
||||||
blobProgress := int64(0)
|
blobProgress := int64(0)
|
||||||
var blockProgress []int64
|
progressLock := &sync.Mutex{}
|
||||||
var progressLock *sync.Mutex
|
|
||||||
if o.Progress != nil {
|
|
||||||
// Optimization: allocate only if progress reporting requested
|
|
||||||
blockProgress = make([]int64, numBlocks) // Potentially 50,000 * 8 = 400,000 bytes!
|
|
||||||
progressLock = &sync.Mutex{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add each put block to the channel
|
// Add each put block to the channel
|
||||||
for blockNum := uint16(0); blockNum < numBlocks; blockNum++ {
|
for blockNum := uint16(0); blockNum < numBlocks; blockNum++ {
|
||||||
|
@ -126,10 +120,11 @@ func UploadBufferToBlockBlob(ctx context.Context, b []byte,
|
||||||
var body io.ReadSeeker = bytes.NewReader(b[offset : offset+blockSize])
|
var body io.ReadSeeker = bytes.NewReader(b[offset : offset+blockSize])
|
||||||
capturedBlockNum := blockNum
|
capturedBlockNum := blockNum
|
||||||
if o.Progress != nil {
|
if o.Progress != nil {
|
||||||
|
blockProgress := int64(0)
|
||||||
body = pipeline.NewRequestBodyProgress(body,
|
body = pipeline.NewRequestBodyProgress(body,
|
||||||
func(bytesTransferred int64) {
|
func(bytesTransferred int64) {
|
||||||
diff := bytesTransferred - blockProgress[capturedBlockNum]
|
diff := bytesTransferred - blockProgress
|
||||||
blockProgress[capturedBlockNum] = bytesTransferred
|
blockProgress = bytesTransferred
|
||||||
progressLock.Lock()
|
progressLock.Lock()
|
||||||
blobProgress += diff
|
blobProgress += diff
|
||||||
o.Progress(blobProgress)
|
o.Progress(blobProgress)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче