ClickHouse/dbms/include/DB/DataStreams/VerticalRowOutputStream.h

56 lines
1.3 KiB
C++
Raw Normal View History

2011-11-28 04:05:53 +00:00
#pragma once
#include <DB/Core/Block.h>
#include <DB/Core/Names.h>
#include <DB/DataStreams/IRowOutputStream.h>
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_, 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;
2011-11-28 04:05:53 +00:00
2016-08-13 01:57:35 +00:00
void flush() override;
protected:
virtual void writeValue(const IColumn & column, const IDataType & type, size_t row_num) const;
2011-11-28 04:05:53 +00:00
WriteBuffer & ostr;
2012-10-10 18:32:45 +00:00
const Block sample;
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;
2011-11-28 04:05:53 +00:00
};
/** Same but values are printed without escaping.
*/
class VerticalRawRowOutputStream final : public VerticalRowOutputStream
{
public:
VerticalRawRowOutputStream(WriteBuffer & ostr_, const Block & sample_, const Context & context)
: VerticalRowOutputStream(ostr_, sample_, context) {}
protected:
void writeValue(const IColumn & column, const IDataType & type, size_t row_num) const override;
};
2011-11-28 04:05:53 +00:00
}