ClickHouse/dbms/src/Formats/ValuesRowOutputStream.cpp

64 lines
1.3 KiB
C++
Raw Normal View History

#include <Formats/ValuesRowOutputStream.h>
#include <Formats/FormatFactory.h>
#include <Formats/BlockOutputStreamFromRowOutputStream.h>
2011-10-30 05:19:41 +00:00
#include <IO/WriteHelpers.h>
#include <Columns/IColumn.h>
#include <DataTypes/IDataType.h>
2011-10-30 05:19:41 +00:00
namespace DB
{
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()
{
ostr.next();
2016-08-13 01:57:35 +00:00
}
void ValuesRowOutputStream::writeField(const IColumn & column, const IDataType & type, size_t row_num)
2011-10-30 05:19:41 +00:00
{
type.serializeTextQuoted(column, row_num, ostr, format_settings);
2011-10-30 05:19:41 +00:00
}
void ValuesRowOutputStream::writeFieldDelimiter()
{
writeChar(',', ostr);
2011-10-30 05:19:41 +00:00
}
void ValuesRowOutputStream::writeRowStartDelimiter()
{
writeChar('(', ostr);
2011-10-30 05:19:41 +00:00
}
void ValuesRowOutputStream::writeRowEndDelimiter()
{
writeChar(')', ostr);
2011-10-30 05:19:41 +00:00
}
void ValuesRowOutputStream::writeRowBetweenDelimiter()
{
writeCString(",", ostr);
2011-10-30 05:19:41 +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
}