2011-11-07 01:15:37 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <DB/DataStreams/IBlockOutputStream.h>
|
|
|
|
|
|
2013-02-16 13:53:33 +00:00
|
|
|
|
#define PRETTY_FORMAT_DEFAULT_MAX_ROWS 10000
|
2011-11-07 04:51:37 +00:00
|
|
|
|
|
2011-11-07 01:15:37 +00:00
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/** Выводит результат в виде красивых таблиц.
|
|
|
|
|
*/
|
|
|
|
|
class PrettyBlockOutputStream : public IBlockOutputStream
|
|
|
|
|
{
|
|
|
|
|
public:
|
2012-06-25 05:07:34 +00:00
|
|
|
|
/// no_escapes - не использовать ANSI escape sequences - для отображения в браузере, а не в консоли.
|
|
|
|
|
PrettyBlockOutputStream(WriteBuffer & ostr_, bool no_escapes_ = false, size_t max_rows_ = PRETTY_FORMAT_DEFAULT_MAX_ROWS);
|
2011-11-07 01:15:37 +00:00
|
|
|
|
void write(const Block & block);
|
2011-11-07 04:51:37 +00:00
|
|
|
|
void writeSuffix();
|
2011-11-07 01:15:37 +00:00
|
|
|
|
|
2011-11-28 04:05:53 +00:00
|
|
|
|
protected:
|
|
|
|
|
typedef std::vector<size_t> Widths_t;
|
|
|
|
|
|
|
|
|
|
/// Вычислить видимую (при выводе на консоль с кодировкой UTF-8) ширину значений и имён столбцов.
|
|
|
|
|
void calculateWidths(Block & block, Widths_t & max_widths, Widths_t & name_widths);
|
|
|
|
|
|
2011-11-07 01:15:37 +00:00
|
|
|
|
WriteBuffer & ostr;
|
2011-11-07 04:51:37 +00:00
|
|
|
|
size_t max_rows;
|
2011-11-07 01:15:37 +00:00
|
|
|
|
size_t total_rows;
|
2011-11-07 04:51:37 +00:00
|
|
|
|
size_t terminal_width;
|
2012-06-25 05:07:34 +00:00
|
|
|
|
|
|
|
|
|
bool no_escapes;
|
2011-11-07 01:15:37 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|