ClickHouse/dbms/src/Storages/StorageS3.h

68 lines
1.6 KiB
C++
Raw Normal View History

2019-05-23 09:03:39 +00:00
#pragma once
#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>
namespace DB
{
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-06-01 21:18:20 +00:00
StorageS3(const Poco::URI & uri_,
const std::string & table_name_,
const String & format_name_,
const ColumnsDescription & columns_,
Context & context_
)
: IStorage(columns_)
, uri(uri_)
, context_global(context_)
, format_name(format_name_)
, table_name(table_name_)
{
}
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-05-31 07:27:14 +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
protected:
2019-05-31 07:27:14 +00:00
Poco::URI uri;
const Context & context_global;
2019-05-23 09:03:39 +00:00
2019-05-31 07:27:14 +00:00
private:
String format_name;
String table_name;
2019-05-23 09:03:39 +00:00
};
}