2011-08-09 19:19:00 +00:00
|
|
|
|
#pragma once
|
2010-03-04 19:20:28 +00:00
|
|
|
|
|
|
|
|
|
#include <Poco/SharedPtr.h>
|
|
|
|
|
|
2011-11-06 05:01:42 +00:00
|
|
|
|
#include <DB/Core/Block.h>
|
2010-06-04 18:25:25 +00:00
|
|
|
|
#include <DB/IO/WriteBuffer.h>
|
2010-03-04 19:20:28 +00:00
|
|
|
|
#include <DB/DataStreams/IRowOutputStream.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
using Poco::SharedPtr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Интерфейс потока для вывода данных в формате tsv.
|
|
|
|
|
*/
|
|
|
|
|
class TabSeparatedRowOutputStream : public IRowOutputStream
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-11-06 06:22:52 +00:00
|
|
|
|
/** with_names - выводить в первой строке заголовок с именами столбцов
|
|
|
|
|
* with_types - выводить на следующей строке заголовок с именами типов
|
|
|
|
|
*/
|
|
|
|
|
TabSeparatedRowOutputStream(WriteBuffer & ostr_, const Block & sample_, bool with_names_ = false, bool with_types_ = false);
|
2010-03-04 19:20:28 +00:00
|
|
|
|
|
|
|
|
|
void writeField(const Field & field);
|
|
|
|
|
void writeFieldDelimiter();
|
|
|
|
|
void writeRowEndDelimiter();
|
2011-11-06 06:22:52 +00:00
|
|
|
|
void writePrefix();
|
2010-03-04 19:20:28 +00:00
|
|
|
|
|
2011-11-06 05:01:42 +00:00
|
|
|
|
RowOutputStreamPtr clone() { return new TabSeparatedRowOutputStream(ostr, sample); }
|
2011-10-24 12:10:59 +00:00
|
|
|
|
|
2010-03-04 19:20:28 +00:00
|
|
|
|
private:
|
2010-06-04 18:25:25 +00:00
|
|
|
|
WriteBuffer & ostr;
|
2011-11-06 05:01:42 +00:00
|
|
|
|
const Block & sample;
|
2011-11-06 06:22:52 +00:00
|
|
|
|
bool with_names;
|
|
|
|
|
bool with_types;
|
2011-11-06 05:01:42 +00:00
|
|
|
|
DataTypes data_types;
|
2010-03-04 19:20:28 +00:00
|
|
|
|
size_t field_number;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|