2011-10-24 12:10:59 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <DataStreams/IBlockOutputStream.h>
|
2018-06-10 19:22:49 +00:00
|
|
|
#include <Formats/IRowOutputStream.h>
|
2011-10-24 12:10:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-05-13 22:19:04 +00:00
|
|
|
/** Transforms a stream to write data by rows to a stream to write data by blocks.
|
|
|
|
* For example, to write a text dump.
|
2011-10-24 12:10:59 +00:00
|
|
|
*/
|
|
|
|
class BlockOutputStreamFromRowOutputStream : public IBlockOutputStream
|
|
|
|
{
|
|
|
|
public:
|
2018-02-19 00:45:32 +00:00
|
|
|
BlockOutputStreamFromRowOutputStream(RowOutputStreamPtr row_output_, const Block & header_);
|
|
|
|
|
|
|
|
Block getHeader() const override { return header; }
|
2017-04-01 07:20:54 +00:00
|
|
|
void write(const Block & block) override;
|
|
|
|
void writePrefix() override { row_output->writePrefix(); }
|
|
|
|
void writeSuffix() override { row_output->writeSuffix(); }
|
2014-11-08 23:52:18 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void flush() override { row_output->flush(); }
|
2014-11-08 23:52:18 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void setRowsBeforeLimit(size_t rows_before_limit) override;
|
|
|
|
void setTotals(const Block & totals) override;
|
|
|
|
void setExtremes(const Block & extremes) override;
|
|
|
|
void onProgress(const Progress & progress) override;
|
2011-10-24 12:10:59 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getContentType() const override { return row_output->getContentType(); }
|
2015-10-29 20:38:37 +00:00
|
|
|
|
2011-10-24 12:10:59 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
RowOutputStreamPtr row_output;
|
2018-02-19 00:45:32 +00:00
|
|
|
Block header;
|
|
|
|
bool first_row = true;
|
2011-10-24 12:10:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|