ClickHouse/dbms/src/DataStreams/BlockOutputStreamFromRowOutputStream.cpp

54 lines
1.2 KiB
C++
Raw Normal View History

2011-10-24 12:10:59 +00:00
#include <DB/DataStreams/BlockOutputStreamFromRowOutputStream.h>
2013-05-22 14:57:43 +00:00
#include <DB/DataStreams/JSONRowOutputStream.h>
2011-10-24 12:10:59 +00:00
namespace DB
{
BlockOutputStreamFromRowOutputStream::BlockOutputStreamFromRowOutputStream(RowOutputStreamPtr row_output_)
2012-05-08 11:38:00 +00:00
: 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();
for (size_t i = 0; i < rows; ++i)
{
2012-05-08 11:38:00 +00:00
if (!first_row)
2011-10-30 05:19:41 +00:00
row_output->writeRowBetweenDelimiter();
2012-05-08 11:38:00 +00:00
first_row = false;
2011-10-24 12:10:59 +00:00
row_output->writeRowStartDelimiter();
for (size_t j = 0; j < columns; ++j)
{
if (j != 0)
row_output->writeFieldDelimiter();
auto & col = block.unsafeGetByPosition(j);
row_output->writeField(*col.column.get(), *col.type.get(), i);
2011-10-24 12:10:59 +00:00
}
2011-10-24 12:10:59 +00:00
row_output->writeRowEndDelimiter();
}
}
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);
}
2011-10-24 12:10:59 +00:00
}