1 | #pragma once |
---|---|
2 | |
3 | #include <DataStreams/materializeBlock.h> |
4 | #include <DataStreams/IBlockOutputStream.h> |
5 | |
6 | |
7 | namespace DB |
8 | { |
9 | |
10 | /** Converts columns-constants to full columns ("materializes" them). |
11 | */ |
12 | class MaterializingBlockOutputStream : public IBlockOutputStream |
13 | { |
14 | public: |
15 | MaterializingBlockOutputStream(const BlockOutputStreamPtr & output_, const Block & header_) |
16 | : output{output_}, header(header_) {} |
17 | |
18 | Block getHeader() const override { return header; } |
19 | void write(const Block & block) override { output->write(materializeBlock(block)); } |
20 | void flush() override { output->flush(); } |
21 | void writePrefix() override { output->writePrefix(); } |
22 | void writeSuffix() override { output->writeSuffix(); } |
23 | void setRowsBeforeLimit(size_t rows_before_limit) override { output->setRowsBeforeLimit(rows_before_limit); } |
24 | void setTotals(const Block & totals) override { output->setTotals(materializeBlock(totals)); } |
25 | void setExtremes(const Block & extremes) override { output->setExtremes(materializeBlock(extremes)); } |
26 | void onProgress(const Progress & progress) override { output->onProgress(progress); } |
27 | String getContentType() const override { return output->getContentType(); } |
28 | |
29 | private: |
30 | BlockOutputStreamPtr output; |
31 | Block header; |
32 | }; |
33 | |
34 | } |
35 |