ClickHouse/dbms/src/DataStreams/VerticalRowOutputStream.h

68 lines
1.7 KiB
C++
Raw Normal View History

2011-11-28 04:05:53 +00:00
#pragma once
#include <Core/Block.h>
#include <Core/Names.h>
#include <DataStreams/IRowOutputStream.h>
2011-11-28 04:05:53 +00:00
namespace DB
{
2016-08-13 01:57:35 +00:00
class WriteBuffer;
class Context;
2016-08-13 01:57:35 +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:
VerticalRowOutputStream(WriteBuffer & ostr_, const Block & sample_, size_t max_rows_, const Context & context);
2011-11-28 04:05:53 +00:00
void writeField(const IColumn & column, const IDataType & type, size_t row_num) override;
void writeRowStartDelimiter() override;
void writeRowBetweenDelimiter() override;
void writeSuffix() override;
2011-11-28 04:05:53 +00:00
void flush() override;
void setTotals(const Block & totals_) override { totals = totals_; }
void setExtremes(const Block & extremes_) override { extremes = extremes_; }
protected:
virtual void writeValue(const IColumn & column, const IDataType & type, size_t row_num) const;
void writeTotals();
void writeExtremes();
/// For totals and extremes.
void writeSpecialRow(const Block & block, size_t row_num, const char * title);
WriteBuffer & ostr;
const Block sample;
size_t max_rows;
size_t field_number = 0;
size_t row_number = 0;
2011-11-28 04:05:53 +00:00
using NamesAndPaddings = std::vector<String>;
NamesAndPaddings names_and_paddings;
Block totals;
Block extremes;
2011-11-28 04:05:53 +00:00
};
/** Same but values are printed without escaping.
*/
class VerticalRawRowOutputStream final : public VerticalRowOutputStream
{
public:
using VerticalRowOutputStream::VerticalRowOutputStream;
protected:
void writeValue(const IColumn & column, const IDataType & type, size_t row_num) const override;
};
2011-11-28 04:05:53 +00:00
}