ClickHouse/dbms/src/Storages/StorageS3.h

76 lines
1.9 KiB
C++
Raw Normal View History

2019-05-23 09:03:39 +00:00
#pragma once
2019-12-06 14:37:21 +00:00
#include <Common/config.h>
#if USE_AWS_S3
2019-05-23 09:03:39 +00:00
#include <Storages/IStorage.h>
2019-05-29 12:54:31 +00:00
#include <Poco/URI.h>
2019-05-23 09:03:39 +00:00
#include <common/logger_useful.h>
#include <ext/shared_ptr_helper.h>
2019-12-03 16:23:24 +00:00
#include <aws/s3/S3Client.h>
2019-09-22 22:13:42 +00:00
2019-05-23 09:03:39 +00:00
namespace DB
{
2019-12-03 16:23:24 +00:00
2019-05-31 07:27:14 +00:00
/**
2019-06-01 21:18:20 +00:00
* This class represents table engine for external S3 urls.
2019-05-31 07:27:14 +00:00
* It sends HTTP GET to server when select is called and
2019-06-01 21:18:20 +00:00
* HTTP PUT when insert is called.
2019-05-31 07:27:14 +00:00
*/
2019-06-01 21:18:20 +00:00
class StorageS3 : public ext::shared_ptr_helper<StorageS3>, public IStorage
2019-05-23 09:03:39 +00:00
{
public:
2019-12-06 14:37:21 +00:00
StorageS3(const S3::URI & uri,
const String & access_key_id,
const String & secret_access_key,
const String & database_name_,
const String & table_name_,
2019-06-01 21:18:20 +00:00
const String & format_name_,
UInt64 min_upload_part_size_,
2019-06-01 21:18:20 +00:00
const ColumnsDescription & columns_,
2019-09-22 22:13:42 +00:00
const ConstraintsDescription & constraints_,
Context & context_,
const String & compression_method_);
2019-06-01 21:18:20 +00:00
String getName() const override
{
return "S3";
}
Block getHeaderBlock(const Names & /*column_names*/) const
{
return getSampleBlock();
}
2019-05-31 07:27:14 +00:00
String getTableName() const override
2019-05-23 09:03:39 +00:00
{
return table_name;
}
2019-09-22 22:13:42 +00:00
BlockInputStreams read(
const Names & column_names,
2019-05-23 09:03:39 +00:00
const SelectQueryInfo & query_info,
const Context & context,
QueryProcessingStage::Enum processed_stage,
size_t max_block_size,
unsigned num_streams) override;
2019-05-31 07:27:14 +00:00
BlockOutputStreamPtr write(const ASTPtr & query, const Context & context) override;
2019-05-23 09:03:39 +00:00
2019-09-04 16:10:25 +00:00
void rename(const String & new_path_to_db, const String & new_database_name, const String & new_table_name, TableStructureWriteLockHolder &) override;
2019-05-23 09:03:39 +00:00
2019-09-22 22:13:42 +00:00
private:
2019-12-06 14:37:21 +00:00
S3::URI uri;
2019-05-31 07:27:14 +00:00
const Context & context_global;
2019-05-23 09:03:39 +00:00
2019-05-31 07:27:14 +00:00
String format_name;
2019-09-12 11:57:55 +00:00
String database_name;
2019-05-31 07:27:14 +00:00
String table_name;
UInt64 min_upload_part_size;
String compression_method;
2019-12-03 16:23:24 +00:00
std::shared_ptr<Aws::S3::S3Client> client;
2019-05-23 09:03:39 +00:00
};
}
#endif