ClickHouse/dbms/src/Storages/LiveView/StorageBlocks.h

52 lines
1.7 KiB
C++
Raw Normal View History

#pragma once
#include <Storages/IStorage.h>
2019-12-05 11:53:36 +00:00
namespace DB
{
2019-12-05 11:53:36 +00:00
class StorageBlocks : public IStorage
{
2019-12-05 11:53:36 +00:00
/* Storage based on the prepared streams that already contain data blocks.
* Used by Live Views to complete stored query based on the mergeable blocks.
*/
public:
StorageBlocks(const std::string & database_name_, const std::string & table_name_,
2019-12-05 13:26:47 +00:00
const ColumnsDescription & columns_, BlockInputStreams streams_,
QueryProcessingStage::Enum to_stage_)
: database_name(database_name_), table_name(table_name_), streams(streams_), to_stage(to_stage_)
{
setColumns(columns_);
}
2019-12-05 11:53:36 +00:00
static StoragePtr createStorage(std::string database_name, std::string table_name,
const ColumnsDescription columns, BlockInputStreams streams, QueryProcessingStage::Enum to_stage)
{
return std::make_shared<StorageBlocks>(std::move(database_name), std::move(table_name), std::move(columns), std::move(streams), to_stage);
}
std::string getName() const override { return "Blocks"; }
std::string getTableName() const override { return table_name; }
std::string getDatabaseName() const override { return database_name; }
QueryProcessingStage::Enum getQueryProcessingStage(const Context & /*context*/) const override { return to_stage; }
BlockInputStreams read(
const Names & /*column_names*/,
const SelectQueryInfo & /*query_info*/,
const Context & /*context*/,
QueryProcessingStage::Enum /*processed_stage*/,
size_t /*max_block_size*/,
2019-12-05 11:53:36 +00:00
unsigned /*num_streams*/)
{
2019-12-05 13:26:47 +00:00
return streams;
}
private:
std::string database_name;
std::string table_name;
Block res_block;
BlockInputStreams streams;
QueryProcessingStage::Enum to_stage;
};
}