1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#pragma once
#include <Processors/Formats/Impl/JSONColumnsBlockOutputFormat.h>
namespace DB
{
/* Format JSONColumnsWithMetadata outputs all data as a single block in the next format:
* {
* "meta":
* [
* {
* "name": "name1",
* "type": "type1"
* },
* {
* "name": "name2",
* "type": "type2"
* },
* ...
* ],
*
* "data":
* {
* "name1": [value1, value2, value3, ...],
* "name2": [value1, value2m value3, ...],
* ...
* },
*
* "rows": ...,
*
* "statistics":
* {
* "elapsed": ...,
* "rows_read": ...,
* "bytes_read": ...
* }
* }
*/
class JSONColumnsWithMetadataBlockOutputFormat : public JSONColumnsBlockOutputFormat
{
public:
JSONColumnsWithMetadataBlockOutputFormat(WriteBuffer & out_, const Block & header_, const FormatSettings & format_settings_);
String getName() const override { return "JSONCompactColumnsBlockOutputFormat"; }
void setRowsBeforeLimit(size_t rows_before_limit_) override { statistics.rows_before_limit = rows_before_limit_; statistics.applied_limit = true; }
void onProgress(const Progress & progress_) override { statistics.progress.incrementPiecewiseAtomically(progress_); }
protected:
void consumeTotals(Chunk chunk) override;
void consumeExtremes(Chunk chunk) override;
void writePrefix() override;
void writeSuffix() override;
void finalizeImpl() override;
void resetFormatterImpl() override;
void writeChunkStart() override;
void writeChunkEnd() override;
void writeExtremesElement(const char * title, const Columns & columns, size_t row_num);
DataTypes types;
size_t rows;
};
}
|