2018-06-10 19:22:49 +00:00
|
|
|
#include <Formats/ValuesRowOutputStream.h>
|
|
|
|
#include <Formats/FormatFactory.h>
|
|
|
|
#include <Formats/BlockOutputStreamFromRowOutputStream.h>
|
2011-10-30 05:19:41 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <IO/WriteHelpers.h>
|
|
|
|
#include <Columns/IColumn.h>
|
|
|
|
#include <DataTypes/IDataType.h>
|
2011-10-30 05:19:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2018-06-08 01:51:55 +00:00
|
|
|
ValuesRowOutputStream::ValuesRowOutputStream(WriteBuffer & ostr_, const FormatSettings & format_settings)
|
|
|
|
: ostr(ostr_), format_settings(format_settings)
|
2011-10-30 05:19:41 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
void ValuesRowOutputStream::flush()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
ostr.next();
|
2016-08-13 01:57:35 +00:00
|
|
|
}
|
|
|
|
|
2016-02-16 16:39:39 +00:00
|
|
|
void ValuesRowOutputStream::writeField(const IColumn & column, const IDataType & type, size_t row_num)
|
2011-10-30 05:19:41 +00:00
|
|
|
{
|
2018-06-08 01:51:55 +00:00
|
|
|
type.serializeTextQuoted(column, row_num, ostr, format_settings);
|
2011-10-30 05:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ValuesRowOutputStream::writeFieldDelimiter()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
writeChar(',', ostr);
|
2011-10-30 05:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ValuesRowOutputStream::writeRowStartDelimiter()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
writeChar('(', ostr);
|
2011-10-30 05:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ValuesRowOutputStream::writeRowEndDelimiter()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
writeChar(')', ostr);
|
2011-10-30 05:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ValuesRowOutputStream::writeRowBetweenDelimiter()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
writeCString(",", ostr);
|
2011-10-30 05:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-10 19:22:49 +00:00
|
|
|
void registerOutputFormatValues(FormatFactory & factory)
|
|
|
|
{
|
|
|
|
factory.registerOutputFormat("Values", [](
|
|
|
|
WriteBuffer & buf,
|
|
|
|
const Block & sample,
|
|
|
|
const Context &,
|
|
|
|
const FormatSettings & settings)
|
|
|
|
{
|
|
|
|
return std::make_shared<BlockOutputStreamFromRowOutputStream>(
|
|
|
|
std::make_shared<ValuesRowOutputStream>(buf, settings), sample);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-10-30 05:19:41 +00:00
|
|
|
}
|