mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 03:22:14 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
#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.
|
|
PrettyBlockOutputFormat(WriteBuffer & out_, const Block & header_, const FormatSettings & format_settings_);
|
|
|
|
String getName() const override { return "PrettyBlockOutputFormat"; }
|
|
|
|
void consume(Chunk) override;
|
|
void consumeTotals(Chunk) override;
|
|
void consumeExtremes(Chunk) override;
|
|
|
|
void finalize() override;
|
|
|
|
protected:
|
|
size_t total_rows = 0;
|
|
size_t terminal_width = 0;
|
|
bool suffix_written = false;
|
|
|
|
const FormatSettings format_settings;
|
|
|
|
using Widths = PODArray<size_t>;
|
|
using WidthsPerColumn = std::vector<Widths>;
|
|
|
|
virtual void write(const Chunk & chunk, PortKind port_kind);
|
|
virtual void writeSuffix();
|
|
|
|
|
|
void writeSuffixIfNot()
|
|
{
|
|
if (!suffix_written)
|
|
writeSuffix();
|
|
|
|
suffix_written = true;
|
|
}
|
|
|
|
void calculateWidths(
|
|
const Block & header, const Chunk & chunk,
|
|
WidthsPerColumn & widths, Widths & max_widths, Widths & name_widths);
|
|
|
|
void writeValueWithPadding(
|
|
const IColumn & column, const IDataType & type, size_t row_num, size_t value_width, size_t pad_to_width);
|
|
};
|
|
|
|
}
|