Simple demo illustrating parallel download of blob block from Azure Blob Storage
To download blob blobs in parallel use the BlockBlobDownloader
and call downloadBlobBlocksAsByteArray
BlockBlobDownloader blockBlobDownloader = new BlockBlobDownloader();
byte[] bytes = blockBlobDownloader.downloadBlobBlocksAsByteArray("containerName", "blobName");
For block blobs it's easy enough to download to the blob via an input stream, or the whole blob to a byte array:
blockBlob.downloadToByteArray(bytes, 0);
This works fine, but can often be slow. Azure block blobs are comprised of blocks, each of which is identified by a block ID. These can be downloaded in parallel to optimise the download time (and upload) of the blob in its entirety, by providing offsets and block size to the method:
blob.downloadRangeToByteArray(offset, blockSize, bytes, (int) offset);
By using this and combining it with CompletedFutures we can easily download the blocks in parallel.