2016-03-28 11:19:51 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <DB/Storages/IStorage.h>
|
|
|
|
|
#include <DB/Databases/IDatabase.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class DatabaseCloud;
|
|
|
|
|
|
|
|
|
|
|
2016-04-04 21:41:16 +00:00
|
|
|
|
/** Облачная таблица. Может находиться только в облачной базе данных.
|
|
|
|
|
* При записи в таблицу, данные записываются в локальные таблицы на нескольких серверах облака.
|
2016-03-28 11:19:51 +00:00
|
|
|
|
*/
|
|
|
|
|
class StorageCloud : public IStorage
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
static StoragePtr create(
|
2016-04-04 21:41:16 +00:00
|
|
|
|
DatabasePtr & database_ptr_,
|
2016-03-28 11:19:51 +00:00
|
|
|
|
const std::string & name_,
|
|
|
|
|
NamesAndTypesListPtr columns_,
|
|
|
|
|
const NamesAndTypesList & materialized_columns_,
|
|
|
|
|
const NamesAndTypesList & alias_columns_,
|
|
|
|
|
const ColumnDefaults & column_defaults_);
|
|
|
|
|
|
|
|
|
|
std::string getName() const override { return "Cloud"; }
|
|
|
|
|
std::string getTableName() const override { return name; }
|
|
|
|
|
|
2016-04-04 21:41:16 +00:00
|
|
|
|
/// Проверка откладывается до метода read. Там проверяется поддержка у использующихся таблиц.
|
2016-03-28 11:19:51 +00:00
|
|
|
|
bool supportsSampling() const override { return true; }
|
|
|
|
|
bool supportsPrewhere() const override { return true; }
|
|
|
|
|
bool supportsFinal() const override { return true; }
|
|
|
|
|
bool supportsIndexForIn() const override { return true; }
|
|
|
|
|
|
|
|
|
|
const NamesAndTypesList & getColumnsListImpl() const override { return *columns; }
|
|
|
|
|
NameAndTypePair getColumn(const String & column_name) const override;
|
|
|
|
|
bool hasColumn(const String & column_name) const override;
|
|
|
|
|
|
|
|
|
|
BlockInputStreams read(
|
|
|
|
|
const Names & column_names,
|
|
|
|
|
ASTPtr query,
|
|
|
|
|
const Context & context,
|
|
|
|
|
const Settings & settings,
|
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
|
size_t max_block_size = DEFAULT_BLOCK_SIZE,
|
|
|
|
|
unsigned threads = 1) override;
|
|
|
|
|
|
2016-04-04 21:41:16 +00:00
|
|
|
|
void drop() override {} /// Вся нужная работа в DatabaseCloud::removeTable
|
2016-03-28 11:19:51 +00:00
|
|
|
|
|
|
|
|
|
void rename(const String & new_path_to_db, const String & new_database_name, const String & new_table_name) override
|
|
|
|
|
{
|
|
|
|
|
name = new_table_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
String name;
|
|
|
|
|
NamesAndTypesListPtr columns;
|
|
|
|
|
|
2016-04-04 21:41:16 +00:00
|
|
|
|
std::weak_ptr<IDatabase> database_ptr;
|
2016-03-28 11:19:51 +00:00
|
|
|
|
|
|
|
|
|
StorageCloud(
|
2016-04-04 21:41:16 +00:00
|
|
|
|
DatabasePtr & database_ptr_,
|
2016-03-28 11:19:51 +00:00
|
|
|
|
const std::string & name_,
|
|
|
|
|
NamesAndTypesListPtr columns_,
|
|
|
|
|
const NamesAndTypesList & materialized_columns_,
|
|
|
|
|
const NamesAndTypesList & alias_columns_,
|
|
|
|
|
const ColumnDefaults & column_defaults_);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|