2011-11-07 01:15:37 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2017-01-21 04:24:28 +00:00
|
|
|
|
#include <DB/Core/Block.h>
|
2011-11-07 01:15:37 +00:00
|
|
|
|
#include <DB/DataStreams/IBlockOutputStream.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
|
class WriteBuffer;
|
2016-12-30 00:15:50 +00:00
|
|
|
|
class Context;
|
2016-08-13 01:57:35 +00:00
|
|
|
|
|
|
|
|
|
|
2011-11-07 01:15:37 +00:00
|
|
|
|
/** Выводит результат в виде красивых таблиц.
|
|
|
|
|
*/
|
|
|
|
|
class PrettyBlockOutputStream : public IBlockOutputStream
|
|
|
|
|
{
|
|
|
|
|
public:
|
2012-06-25 05:07:34 +00:00
|
|
|
|
/// no_escapes - не использовать ANSI escape sequences - для отображения в браузере, а не в консоли.
|
2016-12-30 00:15:50 +00:00
|
|
|
|
PrettyBlockOutputStream(WriteBuffer & ostr_, bool no_escapes_, size_t max_rows_, const Context & context_);
|
2011-11-07 01:15:37 +00:00
|
|
|
|
|
2014-11-08 23:52:18 +00:00
|
|
|
|
void write(const Block & block) override;
|
|
|
|
|
void writeSuffix() override;
|
2014-08-14 20:27:41 +00:00
|
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
|
void flush() override;
|
2014-11-08 23:52:18 +00:00
|
|
|
|
|
|
|
|
|
void setTotals(const Block & totals_) override { totals = totals_; }
|
|
|
|
|
void setExtremes(const Block & extremes_) override { extremes = extremes_; }
|
2014-03-02 19:16:45 +00:00
|
|
|
|
|
2011-11-28 04:05:53 +00:00
|
|
|
|
protected:
|
2014-03-02 19:16:45 +00:00
|
|
|
|
void writeTotals();
|
|
|
|
|
void writeExtremes();
|
|
|
|
|
|
2016-05-28 10:35:44 +00:00
|
|
|
|
using Widths_t = std::vector<size_t>;
|
2011-11-28 04:05:53 +00:00
|
|
|
|
|
|
|
|
|
/// Вычислить видимую (при выводе на консоль с кодировкой UTF-8) ширину значений и имён столбцов.
|
|
|
|
|
void calculateWidths(Block & block, Widths_t & max_widths, Widths_t & name_widths);
|
2014-11-08 23:52:18 +00:00
|
|
|
|
|
2011-11-07 01:15:37 +00:00
|
|
|
|
WriteBuffer & ostr;
|
2011-11-07 04:51:37 +00:00
|
|
|
|
size_t max_rows;
|
2016-12-30 00:15:50 +00:00
|
|
|
|
size_t total_rows = 0;
|
|
|
|
|
size_t terminal_width = 0;
|
2012-06-25 05:07:34 +00:00
|
|
|
|
|
|
|
|
|
bool no_escapes;
|
2014-03-02 19:16:45 +00:00
|
|
|
|
|
|
|
|
|
Block totals;
|
|
|
|
|
Block extremes;
|
2016-12-30 00:15:50 +00:00
|
|
|
|
|
|
|
|
|
const Context & context;
|
2011-11-07 01:15:37 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|