2017-04-01 09:19:00 +00:00
|
|
|
#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_)
|
2017-04-01 07:20:54 +00:00
|
|
|
: row_output(row_output_), first_row(true) {}
|
2011-10-24 12:10:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
void BlockOutputStreamFromRowOutputStream::write(const Block & block)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t rows = block.rows();
|
|
|
|
size_t columns = block.columns();
|
2011-10-24 12:10:59 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
for (size_t i = 0; i < rows; ++i)
|
|
|
|
{
|
|
|
|
if (!first_row)
|
|
|
|
row_output->writeRowBetweenDelimiter();
|
|
|
|
first_row = false;
|
2016-02-16 16:39:39 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
row_output->writeRowStartDelimiter();
|
2011-10-24 12:10:59 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
for (size_t j = 0; j < columns; ++j)
|
|
|
|
{
|
|
|
|
if (j != 0)
|
|
|
|
row_output->writeFieldDelimiter();
|
2016-02-16 16:39:39 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
auto & col = block.getByPosition(j);
|
2017-09-01 18:21:01 +00:00
|
|
|
row_output->writeField(*col.column, *col.type, i);
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2016-02-16 16:39:39 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
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)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
row_output->setRowsBeforeLimit(rows_before_limit);
|
2013-09-01 04:55:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BlockOutputStreamFromRowOutputStream::setTotals(const Block & totals)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
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)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
row_output->setExtremes(extremes);
|
2013-09-07 02:03:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-17 03:29:26 +00:00
|
|
|
void BlockOutputStreamFromRowOutputStream::onProgress(const Progress & progress)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
row_output->onProgress(progress);
|
2016-08-17 03:29:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-24 12:10:59 +00:00
|
|
|
}
|