2014-06-16 17:32:31 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <DB/Core/NamesAndTypes.h>
|
|
|
|
|
#include <DB/Storages/IStorage.h>
|
|
|
|
|
#include <DB/DataStreams/NullBlockInputStream.h>
|
|
|
|
|
#include <DB/DataStreams/NullBlockOutputStream.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/** При записи, ничего не делает.
|
|
|
|
|
* При чтении, возвращает пустоту.
|
|
|
|
|
*/
|
|
|
|
|
class StorageNull : public IStorage
|
|
|
|
|
{
|
|
|
|
|
public:
|
2014-09-30 03:08:47 +00:00
|
|
|
|
static StoragePtr create(
|
|
|
|
|
const std::string & name_,
|
|
|
|
|
NamesAndTypesListPtr columns_,
|
2014-10-03 15:30:10 +00:00
|
|
|
|
const NamesAndTypesList & materialized_columns_,
|
2014-09-30 03:08:47 +00:00
|
|
|
|
const NamesAndTypesList & alias_columns_,
|
|
|
|
|
const ColumnDefaults & column_defaults_)
|
2014-06-16 17:32:31 +00:00
|
|
|
|
{
|
2014-10-03 15:30:10 +00:00
|
|
|
|
return (new StorageNull{name_, columns_, materialized_columns_, alias_columns_, column_defaults_})->thisPtr();
|
2014-06-16 17:32:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-03 17:55:36 +00:00
|
|
|
|
std::string getName() const override { return "Null"; }
|
|
|
|
|
std::string getTableName() const override { return name; }
|
2014-06-16 17:32:31 +00:00
|
|
|
|
|
2014-10-10 15:45:43 +00:00
|
|
|
|
const NamesAndTypesList & getColumnsListImpl() const override { return *columns; }
|
2014-06-16 17:32:31 +00:00
|
|
|
|
|
|
|
|
|
BlockInputStreams read(
|
|
|
|
|
const Names & column_names,
|
|
|
|
|
ASTPtr query,
|
2014-12-17 11:53:17 +00:00
|
|
|
|
const Context & context,
|
2014-06-16 17:32:31 +00:00
|
|
|
|
const Settings & settings,
|
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
2014-12-17 11:53:17 +00:00
|
|
|
|
const size_t max_block_size = DEFAULT_BLOCK_SIZE,
|
|
|
|
|
const unsigned threads = 1) override
|
2014-06-16 17:32:31 +00:00
|
|
|
|
{
|
|
|
|
|
return { new NullBlockInputStream };
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-10 20:43:42 +00:00
|
|
|
|
BlockOutputStreamPtr write(ASTPtr query, const Settings & settings) override
|
2014-06-16 17:32:31 +00:00
|
|
|
|
{
|
|
|
|
|
return new NullBlockOutputStream;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-03 17:55:36 +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; }
|
2014-06-16 17:32:31 +00:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
String name;
|
|
|
|
|
NamesAndTypesListPtr columns;
|
|
|
|
|
|
2014-09-30 03:08:47 +00:00
|
|
|
|
StorageNull(
|
|
|
|
|
const std::string & name_,
|
|
|
|
|
NamesAndTypesListPtr columns_,
|
2014-10-03 15:30:10 +00:00
|
|
|
|
const NamesAndTypesList & materialized_columns_,
|
2014-09-30 03:08:47 +00:00
|
|
|
|
const NamesAndTypesList & alias_columns_,
|
|
|
|
|
const ColumnDefaults & column_defaults_)
|
2014-10-03 15:30:10 +00:00
|
|
|
|
: IStorage{materialized_columns_, alias_columns_, column_defaults_}, name(name_), columns(columns_) {}
|
2014-06-16 17:32:31 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|