ClickHouse/dbms/src/IO/ReadBufferFromS3.h

56 lines
1.1 KiB
C++
Raw Normal View History

2019-05-31 10:58:43 +00:00
#pragma once
2019-12-06 14:37:21 +00:00
#include <Common/config.h>
#if USE_AWS_S3
2020-01-28 13:05:37 +00:00
# include <memory>
2020-01-28 13:05:37 +00:00
# include <IO/HTTPCommon.h>
# include <IO/ReadBuffer.h>
# include <aws/s3/model/GetObjectResult.h>
# include "SeekableReadBuffer.h"
2019-12-11 14:21:48 +00:00
namespace Aws::S3
{
2020-01-28 13:05:37 +00:00
class S3Client;
2019-12-11 14:21:48 +00:00
}
2019-05-31 10:58:43 +00:00
namespace DB
{
/**
* Perform S3 HTTP GET request and provide response to read.
*/
class ReadBufferFromS3 : public SeekableReadBuffer
2019-05-31 10:58:43 +00:00
{
2019-12-03 16:23:24 +00:00
private:
std::shared_ptr<Aws::S3::S3Client> client_ptr;
String bucket;
String key;
size_t buffer_size;
bool initialized = false;
off_t offset = 0;
2019-12-03 16:23:24 +00:00
Aws::S3::Model::GetObjectResult read_result;
std::unique_ptr<ReadBuffer> impl;
Logger * log = &Logger::get("ReadBufferFromS3");
2019-12-03 16:23:24 +00:00
2019-05-31 10:58:43 +00:00
public:
2020-01-28 13:05:37 +00:00
explicit ReadBufferFromS3(
std::shared_ptr<Aws::S3::S3Client> client_ptr_,
const String & bucket_,
const String & key_,
2019-12-03 16:23:24 +00:00
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE);
bool nextImpl() override;
off_t seek(off_t off, int whence) override;
private:
std::unique_ptr<ReadBuffer> initialize();
2019-05-31 10:58:43 +00:00
};
}
2019-12-06 14:37:21 +00:00
#endif