1#pragma once
2
3#include <Core/Block.h>
4#include <Formats/FormatSettings.h>
5#include <Processors/Formats/IRowOutputFormat.h>
6
7
8namespace DB
9{
10
11class WriteBuffer;
12class Context;
13
14
15/** Stream to output data in format "each value in separate row".
16 * Usable to show few rows with many columns.
17 */
18class VerticalRowOutputFormat : public IRowOutputFormat
19{
20public:
21 VerticalRowOutputFormat(WriteBuffer & out_, const Block & header_, FormatFactory::WriteCallback callback, const FormatSettings & format_settings_);
22
23 String getName() const override { return "VerticalRowOutputFormat"; }
24
25 void writeField(const IColumn & column, const IDataType & type, size_t row_num) override;
26 void writeRowStartDelimiter() override;
27 void writeRowBetweenDelimiter() override;
28 void writeSuffix() override;
29
30 void writeMinExtreme(const Columns & columns, size_t row_num) override;
31 void writeMaxExtreme(const Columns & columns, size_t row_num) override;
32 void writeTotals(const Columns & columns, size_t row_num) override;
33
34 void writeBeforeTotals() override;
35 void writeBeforeExtremes() override;
36
37protected:
38 virtual void writeValue(const IColumn & column, const IDataType & type, size_t row_num) const;
39
40 /// For totals and extremes.
41 void writeSpecialRow(const Columns & columns, size_t row_num, PortKind port_kind, const char * title);
42
43 const FormatSettings format_settings;
44 size_t field_number = 0;
45 size_t row_number = 0;
46 bool was_totals_written = false;
47
48 using NamesAndPaddings = std::vector<String>;
49 NamesAndPaddings names_and_paddings;
50};
51
52}
53