2011-11-28 04:05:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Block.h>
|
2018-06-10 19:22:49 +00:00
|
|
|
#include <Formats/FormatSettings.h>
|
|
|
|
#include <Formats/IRowOutputStream.h>
|
2011-11-28 04:05:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2016-12-30 00:15:50 +00:00
|
|
|
/** Stream to output data in format "each value in separate row".
|
|
|
|
* Usable to show few rows with many columns.
|
2011-11-28 04:05:53 +00:00
|
|
|
*/
|
|
|
|
class VerticalRowOutputStream : public IRowOutputStream
|
|
|
|
{
|
|
|
|
public:
|
2018-06-08 01:51:55 +00:00
|
|
|
VerticalRowOutputStream(WriteBuffer & ostr_, const Block & sample_, const FormatSettings & format_settings);
|
2011-11-28 04:05:53 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void writeField(const IColumn & column, const IDataType & type, size_t row_num) override;
|
|
|
|
void writeRowStartDelimiter() override;
|
|
|
|
void writeRowBetweenDelimiter() override;
|
2017-05-22 19:00:45 +00:00
|
|
|
void writeSuffix() override;
|
2011-11-28 04:05:53 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void flush() override;
|
2014-08-14 20:27:41 +00:00
|
|
|
|
2017-05-22 19:00:45 +00:00
|
|
|
void setTotals(const Block & totals_) override { totals = totals_; }
|
|
|
|
void setExtremes(const Block & extremes_) override { extremes = extremes_; }
|
|
|
|
|
2015-09-20 04:04:52 +00:00
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
virtual void writeValue(const IColumn & column, const IDataType & type, size_t row_num) const;
|
2015-09-20 04:04:52 +00:00
|
|
|
|
2017-05-22 19:00:45 +00:00
|
|
|
void writeTotals();
|
|
|
|
void writeExtremes();
|
|
|
|
/// For totals and extremes.
|
|
|
|
void writeSpecialRow(const Block & block, size_t row_num, const char * title);
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
WriteBuffer & ostr;
|
|
|
|
const Block sample;
|
2018-06-08 01:51:55 +00:00
|
|
|
const FormatSettings format_settings;
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t field_number = 0;
|
|
|
|
size_t row_number = 0;
|
2011-11-28 04:05:53 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
using NamesAndPaddings = std::vector<String>;
|
|
|
|
NamesAndPaddings names_and_paddings;
|
2017-05-22 19:00:45 +00:00
|
|
|
|
|
|
|
Block totals;
|
|
|
|
Block extremes;
|
2011-11-28 04:05:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|