JSONEachRowRowOutputFormat.h 1.1 KB
Newer Older
N
Nikolai Kochetov 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#pragma once

#include <Core/Block.h>
#include <IO/WriteBuffer.h>
#include <Processors/Formats/IRowOutputFormat.h>
#include <Formats/FormatSettings.h>


namespace DB
{

/** The stream for outputting data in JSON format, by object per line.
  * Does not validate UTF-8.
  */
class JSONEachRowRowOutputFormat : public IRowOutputFormat
{
public:
H
hcz 已提交
18 19 20
    JSONEachRowRowOutputFormat(
        WriteBuffer & out_,
        const Block & header_,
21
        const RowOutputFormatParams & params_,
22
        const FormatSettings & settings_);
N
Nikolai Kochetov 已提交
23 24 25

    String getName() const override { return "JSONEachRowRowOutputFormat"; }

A
Anton Popov 已提交
26
    void writeField(const IColumn & column, const ISerialization & serialization, size_t row_num) override;
N
Nikolai Kochetov 已提交
27 28 29
    void writeFieldDelimiter() override;
    void writeRowStartDelimiter() override;
    void writeRowEndDelimiter() override;
30 31 32
    void writeRowBetweenDelimiter() override;
    void writePrefix() override;
    void writeSuffix() override;
N
Nikolai Kochetov 已提交
33

34 35 36 37 38
protected:
    /// No totals and extremes.
    void consumeTotals(Chunk) override {}
    void consumeExtremes(Chunk) override {}

N
Nikolai Kochetov 已提交
39
    size_t field_number = 0;
40 41

private:
N
Nikolai Kochetov 已提交
42 43 44 45 46 47
    Names fields;

    FormatSettings settings;
};

}