2014-10-13 14:35:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-21 04:24:28 +00:00
|
|
|
#include <DB/Core/Block.h>
|
2014-10-13 14:35:40 +00:00
|
|
|
#include <DB/DataStreams/IBlockOutputStream.h>
|
2017-01-21 04:24:28 +00:00
|
|
|
|
2014-10-13 14:35:40 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** Преобразует столбцы-константы в полноценные столбцы ("материализует" их).
|
|
|
|
*/
|
|
|
|
class MaterializingBlockOutputStream : public IBlockOutputStream
|
|
|
|
{
|
|
|
|
public:
|
2015-01-27 00:52:03 +00:00
|
|
|
MaterializingBlockOutputStream(const BlockOutputStreamPtr & output)
|
|
|
|
: output{output} {}
|
2016-02-25 02:37:31 +00:00
|
|
|
|
|
|
|
void write(const Block & block) override
|
|
|
|
{
|
2017-01-21 04:24:28 +00:00
|
|
|
output->write(materialize(block));
|
2016-02-25 02:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void flush() override { output->flush(); }
|
|
|
|
void writePrefix() override { output->writePrefix(); }
|
|
|
|
void writeSuffix() override { output->writeSuffix(); }
|
|
|
|
void setRowsBeforeLimit(size_t rows_before_limit) override { output->setRowsBeforeLimit(rows_before_limit); }
|
|
|
|
void setTotals(const Block & totals) override { output->setTotals(materialize(totals)); }
|
|
|
|
void setExtremes(const Block & extremes) override { output->setExtremes(materialize(extremes)); }
|
2016-08-17 04:38:19 +00:00
|
|
|
void onProgress(const Progress & progress) override { output->onProgress(progress); }
|
2016-02-25 02:37:31 +00:00
|
|
|
String getContentType() const override { return output->getContentType(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
BlockOutputStreamPtr output;
|
|
|
|
|
2017-01-21 04:24:28 +00:00
|
|
|
static Block materialize(const Block & original_block);
|
2014-10-13 14:35:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|