2017-04-01 09:19:00 +00:00
|
|
|
#include <IO/WriteBuffer.h>
|
|
|
|
#include <Core/Block.h>
|
|
|
|
#include <DataStreams/TabSeparatedBlockOutputStream.h>
|
2011-08-15 21:50:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
void TabSeparatedBlockOutputStream::flush()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
ostr.next();
|
2016-08-13 01:57:35 +00:00
|
|
|
}
|
|
|
|
|
2011-08-15 21:50:08 +00:00
|
|
|
void TabSeparatedBlockOutputStream::write(const Block & block)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t columns = block.columns();
|
|
|
|
for (size_t i = 0; i < columns; ++i)
|
|
|
|
{
|
|
|
|
const ColumnWithTypeAndName & col = block.safeGetByPosition(i);
|
2011-08-15 21:50:08 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t rows = block.rows();
|
|
|
|
for (size_t j = 0; j < rows; ++j)
|
|
|
|
{
|
|
|
|
if (j != 0)
|
|
|
|
ostr.write('\t');
|
2017-09-01 18:21:01 +00:00
|
|
|
col.type->serializeTextEscaped(*col.column, j, ostr);
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
|
|
|
ostr.write('\n');
|
|
|
|
}
|
|
|
|
ostr.write('\n');
|
2011-08-15 21:50:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|