2019-12-04 23:29:37 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Storages/IStorage.h>
|
2020-02-17 16:35:23 +00:00
|
|
|
#include <Processors/Pipe.h>
|
2019-12-04 23:29:37 +00:00
|
|
|
|
2019-12-05 11:53:36 +00:00
|
|
|
|
2019-12-04 23:29:37 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2019-12-05 11:53:36 +00:00
|
|
|
|
2019-12-04 23:29:37 +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.
|
|
|
|
*/
|
2019-12-04 23:29:37 +00:00
|
|
|
public:
|
2020-01-09 14:33:58 +00:00
|
|
|
StorageBlocks(const StorageID & table_id_,
|
2020-02-17 16:35:23 +00:00
|
|
|
const ColumnsDescription & columns_, Pipes pipes_,
|
2019-12-05 13:26:47 +00:00
|
|
|
QueryProcessingStage::Enum to_stage_)
|
2020-02-17 16:35:23 +00:00
|
|
|
: IStorage(table_id_), pipes(std::move(pipes_)), to_stage(to_stage_)
|
2019-12-04 23:29:37 +00:00
|
|
|
{
|
|
|
|
setColumns(columns_);
|
|
|
|
}
|
2020-01-09 14:33:58 +00:00
|
|
|
static StoragePtr createStorage(const StorageID & table_id,
|
2020-02-17 16:35:23 +00:00
|
|
|
const ColumnsDescription & columns, Pipes pipes, QueryProcessingStage::Enum to_stage)
|
2019-12-04 23:29:37 +00:00
|
|
|
{
|
2020-02-17 16:35:23 +00:00
|
|
|
return std::make_shared<StorageBlocks>(table_id, columns, std::move(pipes), to_stage);
|
2019-12-04 23:29:37 +00:00
|
|
|
}
|
|
|
|
std::string getName() const override { return "Blocks"; }
|
2020-03-24 18:00:57 +00:00
|
|
|
QueryProcessingStage::Enum getQueryProcessingStage(const Context &, const ASTPtr &) const override { return to_stage; }
|
2019-12-04 23:29:37 +00:00
|
|
|
|
2020-02-19 16:07:28 +00:00
|
|
|
Pipes read(
|
2019-12-04 23:29:37 +00:00
|
|
|
const Names & /*column_names*/,
|
|
|
|
const SelectQueryInfo & /*query_info*/,
|
|
|
|
const Context & /*context*/,
|
|
|
|
QueryProcessingStage::Enum /*processed_stage*/,
|
|
|
|
size_t /*max_block_size*/,
|
2019-12-06 00:08:40 +00:00
|
|
|
unsigned /*num_streams*/) override
|
2019-12-04 23:29:37 +00:00
|
|
|
{
|
2020-02-17 16:37:18 +00:00
|
|
|
return std::move(pipes);
|
2019-12-04 23:29:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Block res_block;
|
2020-02-17 16:35:23 +00:00
|
|
|
Pipes pipes;
|
2019-12-04 23:29:37 +00:00
|
|
|
QueryProcessingStage::Enum to_stage;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|