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

55 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;
2012-11-10 04:43:04 +00:00
/** Поток для вывода данных в формате "каждое значение на своей строке".
2011-11-28 04:05:53 +00:00
*/
class VerticalRowOutputStream : public IRowOutputStream
{
public:
VerticalRowOutputStream(WriteBuffer & ostr_, const Block & sample_);
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;
2011-11-28 04:05:53 +00:00
Names names;
size_t field_number;
size_t row_number;
using Pads_t = std::vector<String>;
2011-11-28 04:05:53 +00:00
Pads_t pads;
};
/** То же самое, но строки выводятся без экранирования.
*/
class VerticalRawRowOutputStream : public VerticalRowOutputStream
{
public:
VerticalRawRowOutputStream(WriteBuffer & ostr_, const Block & sample_)
: VerticalRowOutputStream(ostr_, sample_) {}
protected:
void writeValue(const IColumn & column, const IDataType & type, size_t row_num) const override;
};
2011-11-28 04:05:53 +00:00
}