2019-02-19 18:41:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Core/Block.h>
|
|
|
|
#include <Processors/Formats/IOutputFormat.h>
|
|
|
|
#include <Formats/FormatSettings.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class WriteBuffer;
|
|
|
|
class Context;
|
|
|
|
|
|
|
|
|
|
|
|
/** Prints the result in the form of beautiful tables.
|
|
|
|
*/
|
|
|
|
class PrettyBlockOutputFormat : public IOutputFormat
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// no_escapes - do not use ANSI escape sequences - to display in the browser, not in the console.
|
2019-08-03 11:02:40 +00:00
|
|
|
PrettyBlockOutputFormat(WriteBuffer & out_, const Block & header_, const FormatSettings & format_settings_);
|
2019-02-19 18:41:18 +00:00
|
|
|
|
|
|
|
String getName() const override { return "PrettyBlockOutputFormat"; }
|
|
|
|
|
2021-11-02 13:40:41 +00:00
|
|
|
protected:
|
2019-02-19 18:41:18 +00:00
|
|
|
void consume(Chunk) override;
|
|
|
|
void consumeTotals(Chunk) override;
|
|
|
|
void consumeExtremes(Chunk) override;
|
|
|
|
|
|
|
|
size_t total_rows = 0;
|
|
|
|
size_t terminal_width = 0;
|
|
|
|
|
2020-09-29 12:30:36 +00:00
|
|
|
size_t row_number_width = 7; // "10000. "
|
|
|
|
|
2019-02-19 18:41:18 +00:00
|
|
|
const FormatSettings format_settings;
|
2022-05-06 16:48:48 +00:00
|
|
|
Serializations serializations;
|
2019-02-19 18:41:18 +00:00
|
|
|
|
|
|
|
using Widths = PODArray<size_t>;
|
|
|
|
using WidthsPerColumn = std::vector<Widths>;
|
|
|
|
|
2022-05-06 16:48:48 +00:00
|
|
|
virtual void write(Chunk chunk, PortKind port_kind);
|
2021-11-17 20:51:46 +00:00
|
|
|
void writeSuffix() override;
|
2019-02-19 18:41:18 +00:00
|
|
|
|
2021-11-25 12:09:13 +00:00
|
|
|
void onRowsReadBeforeUpdate() override { total_rows = getRowsReadBefore(); }
|
2019-02-19 18:41:18 +00:00
|
|
|
|
|
|
|
void calculateWidths(
|
|
|
|
const Block & header, const Chunk & chunk,
|
2020-06-02 13:53:34 +00:00
|
|
|
WidthsPerColumn & widths, Widths & max_padded_widths, Widths & name_widths);
|
2019-02-19 18:41:18 +00:00
|
|
|
|
|
|
|
void writeValueWithPadding(
|
2021-03-09 14:46:52 +00:00
|
|
|
const IColumn & column, const ISerialization & serialization, size_t row_num,
|
|
|
|
size_t value_width, size_t pad_to_width, bool align_right);
|
2019-02-19 18:41:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|