ClickHouse/src/Processors/Formats/Impl/JSONCompactColumnsBlockOutputFormat.cpp
2022-05-20 12:07:29 +00:00

43 lines
1.2 KiB
C++

#include <Processors/Formats/Impl/JSONCompactColumnsBlockOutputFormat.h>
#include <IO/WriteHelpers.h>
#include <Formats/FormatFactory.h>
#include <Formats/JSONUtils.h>
namespace DB
{
JSONCompactColumnsBlockOutputFormat::JSONCompactColumnsBlockOutputFormat(WriteBuffer & out_, const Block & header_, const FormatSettings & format_settings_)
: JSONColumnsBlockOutputFormatBase(out_, header_, format_settings_), column_names(header_.getNames())
{
}
void JSONCompactColumnsBlockOutputFormat::writeChunkStart()
{
JSONUtils::writeArrayStart(*ostr);
}
void JSONCompactColumnsBlockOutputFormat::writeColumnStart(size_t)
{
JSONUtils::writeCompactArrayStart(*ostr, 1);
}
void JSONCompactColumnsBlockOutputFormat::writeChunkEnd()
{
JSONUtils::writeArrayEnd(*ostr);
writeChar('\n', *ostr);
}
void registerOutputFormatJSONCompactColumns(FormatFactory & factory)
{
factory.registerOutputFormat("JSONCompactColumns", [](
WriteBuffer & buf,
const Block & sample,
const RowOutputFormatParams &,
const FormatSettings & format_settings)
{
return std::make_shared<JSONCompactColumnsBlockOutputFormat>(buf, sample, format_settings);
});
}
}