2016-02-18 11:44:50 +00:00
|
|
|
|
#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:
|
2016-10-10 09:04:56 +00:00
|
|
|
|
JSONEachRowRowOutputStream(WriteBuffer & ostr_, const Block & sample, bool force_quoting_64bit_integers_ = true);
|
2016-02-18 11:44:50 +00:00
|
|
|
|
|
|
|
|
|
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;
|
2016-09-30 16:21:09 +00:00
|
|
|
|
bool force_quoting_64bit_integers;
|
2016-02-18 11:44:50 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|