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;
|
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:
|
2016-12-30 00:15:50 +00:00
|
|
|
VerticalRowOutputStream(WriteBuffer & ostr_, const Block & sample_, const Context & context);
|
2011-11-28 04:05:53 +00:00
|
|
|
|
2016-02-16 16:39:39 +00:00
|
|
|
void writeField(const IColumn & column, const IDataType & type, size_t row_num) override;
|
2014-11-08 23:52:18 +00:00
|
|
|
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;
|
2014-08-14 20:27:41 +00:00
|
|
|
|
2015-09-20 04:04:52 +00:00
|
|
|
protected:
|
2016-02-16 16:39:39 +00:00
|
|
|
virtual void writeValue(const IColumn & column, const IDataType & type, size_t row_num) const;
|
2015-09-20 04:04:52 +00:00
|
|
|
|
2011-11-28 04:05:53 +00:00
|
|
|
WriteBuffer & ostr;
|
2012-10-10 18:32:45 +00:00
|
|
|
const Block sample;
|
2016-12-30 00:15:50 +00:00
|
|
|
size_t field_number = 0;
|
|
|
|
size_t row_number = 0;
|
2011-11-28 04:05:53 +00:00
|
|
|
|
2016-12-30 00:15:50 +00:00
|
|
|
using NamesAndPaddings = std::vector<String>;
|
|
|
|
NamesAndPaddings names_and_paddings;
|
2011-11-28 04:05:53 +00:00
|
|
|
};
|
|
|
|
|
2015-09-20 04:04:52 +00:00
|
|
|
|
2016-12-30 00:15:50 +00:00
|
|
|
/** Same but values are printed without escaping.
|
2015-09-20 04:04:52 +00:00
|
|
|
*/
|
2016-12-30 00:15:50 +00:00
|
|
|
class VerticalRawRowOutputStream final : public VerticalRowOutputStream
|
2015-09-20 04:04:52 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-12-30 00:15:50 +00:00
|
|
|
VerticalRawRowOutputStream(WriteBuffer & ostr_, const Block & sample_, const Context & context)
|
|
|
|
: VerticalRowOutputStream(ostr_, sample_, context) {}
|
2015-09-20 04:04:52 +00:00
|
|
|
|
|
|
|
protected:
|
2016-02-16 16:39:39 +00:00
|
|
|
void writeValue(const IColumn & column, const IDataType & type, size_t row_num) const override;
|
2015-09-20 04:04:52 +00:00
|
|
|
};
|
|
|
|
|
2011-11-28 04:05:53 +00:00
|
|
|
}
|
|
|
|
|