blob: 3353fae9fc1754699f513ff6908ca3f34d462605 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#pragma once
#include "clickhouse_config.h"
#if USE_AZURE_BLOB_STORAGE
#include <memory>
#include <IO/WriteBufferFromFileBase.h>
#include <IO/WriteBuffer.h>
#include <IO/WriteSettings.h>
#error #include <azure/storage/blobs.hpp>
#error #include <azure/core/io/body_stream.hpp>
namespace Poco
{
class Logger;
}
namespace DB
{
class WriteBufferFromAzureBlobStorage : public WriteBufferFromFileBase
{
public:
using AzureClientPtr = std::shared_ptr<const Azure::Storage::Blobs::BlobContainerClient>;
WriteBufferFromAzureBlobStorage(
AzureClientPtr blob_container_client_,
const String & blob_path_,
size_t max_single_part_upload_size_,
size_t buf_size_,
const WriteSettings & write_settings_);
~WriteBufferFromAzureBlobStorage() override;
void nextImpl() override;
std::string getFileName() const override { return blob_path; }
void sync() override { next(); }
private:
void finalizeImpl() override;
void execWithRetry(std::function<void()> func, size_t num_tries, size_t cost = 0);
void uploadBlock(const char * data, size_t size);
Poco::Logger * log;
const size_t max_single_part_upload_size;
const std::string blob_path;
const WriteSettings write_settings;
AzureClientPtr blob_container_client;
std::vector<std::string> block_ids;
using MemoryBufferPtr = std::unique_ptr<Memory<>>;
MemoryBufferPtr tmp_buffer;
size_t tmp_buffer_write_offset = 0;
MemoryBufferPtr allocateBuffer() const;
};
}
#endif
|