2012-05-30 05:53:09 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <statdaemons/OptimizedRegularExpression.h>
|
|
|
|
|
|
|
|
|
|
#include <DB/Interpreters/Context.h>
|
|
|
|
|
#include <DB/Storages/IStorage.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/** Таблица, представляющая собой объединение произвольного количества других таблиц.
|
|
|
|
|
* У всех таблиц должна быть одинаковая структура.
|
|
|
|
|
*/
|
|
|
|
|
class StorageMerge : public IStorage
|
|
|
|
|
{
|
|
|
|
|
public:
|
2013-02-06 11:26:35 +00:00
|
|
|
|
static StoragePtr create(
|
2012-05-30 05:53:09 +00:00
|
|
|
|
const std::string & name_, /// Имя таблицы.
|
|
|
|
|
NamesAndTypesListPtr columns_, /// Список столбцов.
|
|
|
|
|
const String & source_database_, /// В какой БД искать таблицы-источники.
|
|
|
|
|
const String & table_name_regexp_, /// Регексп имён таблиц-источников.
|
2013-05-05 18:02:05 +00:00
|
|
|
|
const Context & context_); /// Известные таблицы.
|
2012-05-30 05:53:09 +00:00
|
|
|
|
|
|
|
|
|
std::string getName() const { return "Merge"; }
|
|
|
|
|
std::string getTableName() const { return name; }
|
2012-12-15 04:39:13 +00:00
|
|
|
|
bool supportsSampling() const { return true; }
|
2012-05-30 05:53:09 +00:00
|
|
|
|
|
|
|
|
|
const NamesAndTypesList & getColumnsList() const { return *columns; }
|
|
|
|
|
|
|
|
|
|
BlockInputStreams read(
|
|
|
|
|
const Names & column_names,
|
|
|
|
|
ASTPtr query,
|
2013-02-01 19:02:04 +00:00
|
|
|
|
const Settings & settings,
|
2012-05-30 05:53:09 +00:00
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
|
size_t max_block_size = DEFAULT_BLOCK_SIZE,
|
|
|
|
|
unsigned threads = 1);
|
|
|
|
|
|
2013-01-23 17:43:19 +00:00
|
|
|
|
void dropImpl() {}
|
2012-06-18 06:19:13 +00:00
|
|
|
|
void rename(const String & new_path_to_db, const String & new_name) { name = new_name; }
|
2012-05-30 05:53:09 +00:00
|
|
|
|
|
|
|
|
|
private:
|
2012-06-18 06:19:13 +00:00
|
|
|
|
String name;
|
2012-05-30 05:53:09 +00:00
|
|
|
|
NamesAndTypesListPtr columns;
|
|
|
|
|
String source_database;
|
|
|
|
|
OptimizedRegularExpression table_name_regexp;
|
2013-05-05 18:02:05 +00:00
|
|
|
|
const Context & context;
|
2013-02-06 11:26:35 +00:00
|
|
|
|
|
|
|
|
|
StorageMerge(
|
|
|
|
|
const std::string & name_,
|
|
|
|
|
NamesAndTypesListPtr columns_,
|
|
|
|
|
const String & source_database_,
|
|
|
|
|
const String & table_name_regexp_,
|
2013-05-05 18:02:05 +00:00
|
|
|
|
const Context & context_);
|
2012-05-30 05:53:09 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|