2021-09-29 14:44:53 +00:00
|
|
|
#if !defined(ARCADIA_BUILD)
|
|
|
|
#include <Common/config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_AZURE_BLOB_STORAGE
|
|
|
|
|
|
|
|
#include <IO/WriteBufferFromBlobStorage.h>
|
|
|
|
|
2021-10-01 08:32:28 +00:00
|
|
|
|
2021-09-29 14:44:53 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-10-01 08:32:28 +00:00
|
|
|
WriteBufferFromBlobStorage::WriteBufferFromBlobStorage(
|
|
|
|
Azure::Storage::Blobs::BlobContainerClient blob_container_client_,
|
|
|
|
const String & blob_path_,
|
|
|
|
size_t buf_size_) :
|
2021-10-01 13:41:10 +00:00
|
|
|
BufferWithOwnMemory<WriteBuffer>(buf_size_, nullptr, 0),
|
2021-10-01 08:32:28 +00:00
|
|
|
blob_container_client(blob_container_client_),
|
|
|
|
blob_path(blob_path_),
|
2021-10-01 13:41:10 +00:00
|
|
|
buf_size(buf_size_)
|
|
|
|
{
|
|
|
|
// allocateBuffer();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteBufferFromBlobStorage::allocateBuffer()
|
|
|
|
{
|
2021-10-01 08:32:28 +00:00
|
|
|
|
2021-10-01 13:41:10 +00:00
|
|
|
}
|
2021-10-01 08:32:28 +00:00
|
|
|
|
2021-09-29 14:44:53 +00:00
|
|
|
void WriteBufferFromBlobStorage::nextImpl() {
|
2021-10-01 08:32:28 +00:00
|
|
|
std::cout << "buf_size: " << buf_size << "\n";
|
2021-10-05 12:00:59 +00:00
|
|
|
std::cout << "offset(): " << offset() << "\n";
|
2021-10-01 13:41:10 +00:00
|
|
|
|
|
|
|
if (!offset())
|
|
|
|
return;
|
|
|
|
|
2021-10-05 12:00:59 +00:00
|
|
|
auto pos = working_buffer.begin();
|
|
|
|
auto len = offset();
|
|
|
|
|
|
|
|
std::cout << "buffer contents: ";
|
|
|
|
|
|
|
|
for (size_t i = 0; i < offset(); i++)
|
|
|
|
{
|
2021-10-05 12:46:38 +00:00
|
|
|
std::cout << static_cast<uint8_t>(*(pos + i)) << " ";
|
2021-10-05 12:00:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "\n";
|
|
|
|
|
|
|
|
|
|
|
|
Azure::Core::IO::MemoryBodyStream tmp_buffer(reinterpret_cast<uint8_t *>(pos), len);
|
2021-10-01 13:41:10 +00:00
|
|
|
|
|
|
|
blob_container_client.UploadBlob(blob_path, tmp_buffer);
|
2021-09-29 14:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|