2017-01-21 04:24:28 +00:00
|
|
|
#include <DB/Core/Block.h>
|
2011-10-24 12:10:59 +00:00
|
|
|
#include <DB/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_)
|
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;
|
2016-02-16 16:39:39 +00:00
|
|
|
|
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();
|
2016-02-16 16:39:39 +00:00
|
|
|
|
2017-01-02 20:12:12 +00:00
|
|
|
auto & col = block.getByPosition(j);
|
2016-02-16 16:39:39 +00:00
|
|
|
row_output->writeField(*col.column.get(), *col.type.get(), i);
|
2011-10-24 12:10:59 +00:00
|
|
|
}
|
2016-02-16 16:39:39 +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)
|
|
|
|
{
|
2013-09-01 04:55:41 +00:00
|
|
|
row_output->setRowsBeforeLimit(rows_before_limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BlockOutputStreamFromRowOutputStream::setTotals(const Block & totals)
|
|
|
|
{
|
|
|
|
row_output->setTotals(totals);
|
2013-05-22 14:57:43 +00:00
|
|
|
}
|
|
|
|
|
2013-09-07 02:03:13 +00:00
|
|
|
void BlockOutputStreamFromRowOutputStream::setExtremes(const Block & extremes)
|
|
|
|
{
|
|
|
|
row_output->setExtremes(extremes);
|
|
|
|
}
|
|
|
|
|
2016-08-17 03:29:26 +00:00
|
|
|
void BlockOutputStreamFromRowOutputStream::onProgress(const Progress & progress)
|
|
|
|
{
|
|
|
|
row_output->onProgress(progress);
|
|
|
|
}
|
|
|
|
|
2011-10-24 12:10:59 +00:00
|
|
|
}
|