2011-08-09 19:19:00 +00:00
|
|
|
|
#pragma once
|
2010-03-04 19:20:28 +00:00
|
|
|
|
|
2011-11-06 05:01:42 +00:00
|
|
|
|
#include <DB/Core/Block.h>
|
2010-03-04 19:20:28 +00:00
|
|
|
|
#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
|
|
|
|
/** Поток для вывода данных в формате tsv.
|
2010-03-04 19:20:28 +00:00
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
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 writeFieldDelimiter() override;
|
|
|
|
|
void writeRowEndDelimiter() override;
|
|
|
|
|
void writePrefix() override;
|
|
|
|
|
void writeSuffix() override;
|
2014-03-02 19:16:45 +00:00
|
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
|
void flush() override;
|
2014-08-14 20:27:41 +00:00
|
|
|
|
|
2014-11-08 23:52:18 +00:00
|
|
|
|
void setTotals(const Block & totals_) override { totals = totals_; }
|
|
|
|
|
void setExtremes(const Block & extremes_) override { extremes = extremes_; }
|
2010-03-04 19:20:28 +00:00
|
|
|
|
|
2015-10-30 21:19:54 +00:00
|
|
|
|
/// https://www.iana.org/assignments/media-types/text/tab-separated-values
|
|
|
|
|
String getContentType() const override { return "text/tab-separated-values; charset=UTF-8"; }
|
|
|
|
|
|
2012-08-17 19:53:11 +00:00
|
|
|
|
protected:
|
2014-03-02 19:16:45 +00:00
|
|
|
|
void writeTotals();
|
|
|
|
|
void writeExtremes();
|
|
|
|
|
|
2010-06-04 18:25:25 +00:00
|
|
|
|
WriteBuffer & ostr;
|
2012-10-10 18:32:45 +00:00
|
|
|
|
const Block sample;
|
2011-11-06 06:22:52 +00:00
|
|
|
|
bool with_names;
|
|
|
|
|
bool with_types;
|
2014-03-02 19:16:45 +00:00
|
|
|
|
Block totals;
|
|
|
|
|
Block extremes;
|
2010-03-04 19:20:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|