mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 21:24:28 +00:00
40 lines
858 B
C++
40 lines
858 B
C++
#pragma once
|
|
|
|
#include <Core/Block.h>
|
|
#include <IO/WriteBuffer.h>
|
|
#include <DataStreams/IRowOutputStream.h>
|
|
#include <DataTypes/FormatSettingsJSON.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/** The stream for outputting data in JSON format, by object per line.
|
|
* Does not validate UTF-8.
|
|
*/
|
|
class JSONEachRowRowOutputStream : public IRowOutputStream
|
|
{
|
|
public:
|
|
JSONEachRowRowOutputStream(WriteBuffer & ostr_, const Block & sample, const FormatSettingsJSON & settings);
|
|
|
|
void writeField(const IColumn & column, const IDataType & type, size_t row_num) override;
|
|
void writeFieldDelimiter() override;
|
|
void writeRowStartDelimiter() override;
|
|
void writeRowEndDelimiter() override;
|
|
|
|
void flush() override
|
|
{
|
|
ostr.next();
|
|
}
|
|
|
|
private:
|
|
WriteBuffer & ostr;
|
|
size_t field_number = 0;
|
|
Names fields;
|
|
|
|
FormatSettingsJSON settings;
|
|
};
|
|
|
|
}
|
|
|