ClickHouse/dbms/include/DB/DataStreams/JSONEachRowRowOutputStream.h
2016-02-18 14:44:50 +03:00

37 lines
778 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <DB/Core/Block.h>
#include <DB/IO/WriteBuffer.h>
#include <DB/DataStreams/IRowOutputStream.h>
namespace DB
{
/** Поток для вывода данных в формате JSON, по объекту на каждую строчку.
* Не валидирует UTF-8.
*/
class JSONEachRowRowOutputStream : public IRowOutputStream
{
public:
JSONEachRowRowOutputStream(WriteBuffer & ostr_, const Block & sample);
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;
};
}