This commit is contained in:
kssenii 2021-12-22 14:21:35 +03:00
parent 060d3228e9
commit 65c5334bb0
2 changed files with 2 additions and 25 deletions

View File

@ -12,11 +12,6 @@
namespace DB
{
namespace ErrorCodes
{
extern const int AZURE_BLOB_STORAGE_ERROR;
}
WriteBufferFromAzureBlobStorage::WriteBufferFromAzureBlobStorage(
std::shared_ptr<Azure::Storage::Blobs::BlobContainerClient> blob_container_client_,
const String & blob_path_,
@ -44,6 +39,7 @@ void WriteBufferFromAzureBlobStorage::nextImpl()
auto block_blob_client = blob_container_client->GetBlockBlobClient(blob_path);
size_t read = 0;
std::vector<std::string> block_ids;
while (read < len)
{
auto part_len = std::min(len - read, max_single_part_upload_size);
@ -56,23 +52,8 @@ void WriteBufferFromAzureBlobStorage::nextImpl()
read += part_len;
}
}
void WriteBufferFromAzureBlobStorage::finalizeImpl()
{
next();
try
{
auto block_blob_client = blob_container_client->GetBlockBlobClient(blob_path);
block_blob_client.CommitBlockList(block_ids);
}
catch (const Azure::core::RequestFailedException & e)
{
throw Exception(ErrorCodes::AZURE_BLOB_STORAGE_ERROR, "Azure blob storage commit block list failed: {}", e.message);
}
finalized = true;
block_blob_client.CommitBlockList(block_ids);
}
}

View File

@ -32,10 +32,6 @@ public:
void nextImpl() override;
private:
void finalizeImpl() override;
std::vector<std::string> block_ids;
std::shared_ptr<Azure::Storage::Blobs::BlobContainerClient> blob_container_client;
size_t max_single_part_upload_size;
const String blob_path;