ClickHouse/dbms/src/Formats/BlockOutputStreamFromRowOutputStream.h

39 lines
1.1 KiB
C++
Raw Normal View History

2011-10-24 12:10:59 +00:00
#pragma once
#include <DataStreams/IBlockOutputStream.h>
#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:
BlockOutputStreamFromRowOutputStream(RowOutputStreamPtr row_output_, const Block & header_);
Block getHeader() const override { return header; }
void write(const Block & block) override;
void writePrefix() override { row_output->writePrefix(); }
void writeSuffix() override { row_output->writeSuffix(); }
void flush() override { row_output->flush(); }
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
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:
RowOutputStreamPtr row_output;
Block header;
bool first_row = true;
2011-10-24 12:10:59 +00:00
};
}