ClickHouse/dbms/src/DataStreams/BlockOutputStreamFromRowOutputStream.cpp

60 lines
1.4 KiB
C++
Raw Normal View History

#include <Core/Block.h>
#include <DataStreams/BlockOutputStreamFromRowOutputStream.h>
2016-08-13 01:57:35 +00:00
2011-10-24 12:10:59 +00:00
namespace DB
{
BlockOutputStreamFromRowOutputStream::BlockOutputStreamFromRowOutputStream(RowOutputStreamPtr row_output_)
: row_output(row_output_), first_row(true) {}
2011-10-24 12:10:59 +00:00
void BlockOutputStreamFromRowOutputStream::write(const Block & block)
{
size_t rows = block.rows();
size_t columns = block.columns();
2011-10-24 12:10:59 +00:00
for (size_t i = 0; i < rows; ++i)
{
if (!first_row)
row_output->writeRowBetweenDelimiter();
first_row = false;
row_output->writeRowStartDelimiter();
2011-10-24 12:10:59 +00:00
for (size_t j = 0; j < columns; ++j)
{
if (j != 0)
row_output->writeFieldDelimiter();
auto & col = block.getByPosition(j);
row_output->writeField(*col.column, *col.type, i);
}
row_output->writeRowEndDelimiter();
}
2011-10-24 12:10:59 +00:00
}
2013-05-22 14:57:43 +00:00
void BlockOutputStreamFromRowOutputStream::setRowsBeforeLimit(size_t rows_before_limit)
{
row_output->setRowsBeforeLimit(rows_before_limit);
}
void BlockOutputStreamFromRowOutputStream::setTotals(const Block & totals)
{
row_output->setTotals(totals);
2013-05-22 14:57:43 +00:00
}
void BlockOutputStreamFromRowOutputStream::setExtremes(const Block & extremes)
{
row_output->setExtremes(extremes);
}
void BlockOutputStreamFromRowOutputStream::onProgress(const Progress & progress)
{
row_output->onProgress(progress);
}
2011-10-24 12:10:59 +00:00
}