| 1 | #pragma once |
|---|---|
| 2 | |
| 3 | #include <Core/Block.h> |
| 4 | #include <IO/WriteBuffer.h> |
| 5 | #include <Processors/Formats/IRowOutputFormat.h> |
| 6 | #include <Formats/FormatSettings.h> |
| 7 | |
| 8 | |
| 9 | namespace DB |
| 10 | { |
| 11 | |
| 12 | /** The stream for outputting data in JSON format, by object per line. |
| 13 | * Does not validate UTF-8. |
| 14 | */ |
| 15 | class JSONEachRowRowOutputFormat : public IRowOutputFormat |
| 16 | { |
| 17 | public: |
| 18 | JSONEachRowRowOutputFormat(WriteBuffer & out_, const Block & header_, FormatFactory::WriteCallback callback, const FormatSettings & settings_); |
| 19 | |
| 20 | String getName() const override { return "JSONEachRowRowOutputFormat"; } |
| 21 | |
| 22 | void writeField(const IColumn & column, const IDataType & type, size_t row_num) override; |
| 23 | void writeFieldDelimiter() override; |
| 24 | void writeRowStartDelimiter() override; |
| 25 | void writeRowEndDelimiter() override; |
| 26 | |
| 27 | protected: |
| 28 | /// No totals and extremes. |
| 29 | void consumeTotals(Chunk) override {} |
| 30 | void consumeExtremes(Chunk) override {} |
| 31 | |
| 32 | size_t field_number = 0; |
| 33 | |
| 34 | private: |
| 35 | Names fields; |
| 36 | |
| 37 | FormatSettings settings; |
| 38 | }; |
| 39 | |
| 40 | } |
| 41 |