2011-08-09 19:19:00 +00:00
|
|
|
#pragma once
|
2010-03-04 19:20:28 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Block.h>
|
2018-06-08 01:51:55 +00:00
|
|
|
#include <DataTypes/FormatSettings.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <DataStreams/IRowOutputStream.h>
|
2010-03-04 19:20:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
class WriteBuffer;
|
|
|
|
|
2017-05-13 22:19:04 +00:00
|
|
|
/** A stream for outputting data in tsv format.
|
2010-03-04 19:20:28 +00:00
|
|
|
*/
|
|
|
|
class TabSeparatedRowOutputStream : public IRowOutputStream
|
|
|
|
{
|
|
|
|
public:
|
2017-05-13 22:19:04 +00:00
|
|
|
/** with_names - output in the first line a header with column names
|
|
|
|
* with_types - output the next line header with the names of the types
|
2017-04-01 07:20:54 +00:00
|
|
|
*/
|
2018-06-08 01:51:55 +00:00
|
|
|
TabSeparatedRowOutputStream(WriteBuffer & ostr_, const Block & sample_, bool with_names_, bool with_types_, const FormatSettings & format_settings);
|
2010-03-04 19:20:28 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void writeField(const IColumn & column, const IDataType & type, size_t row_num) override;
|
|
|
|
void writeFieldDelimiter() override;
|
|
|
|
void writeRowEndDelimiter() override;
|
|
|
|
void writePrefix() override;
|
|
|
|
void writeSuffix() override;
|
2014-03-02 19:16:45 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void flush() override;
|
2014-08-14 20:27:41 +00:00
|
|
|
|
2017-04-01 07:20:54 +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
|
|
|
|
2017-04-01 07:20: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"; }
|
2015-10-30 21:19:54 +00:00
|
|
|
|
2012-08-17 19:53:11 +00:00
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
void writeTotals();
|
|
|
|
void writeExtremes();
|
|
|
|
|
|
|
|
WriteBuffer & ostr;
|
|
|
|
const Block sample;
|
|
|
|
bool with_names;
|
|
|
|
bool with_types;
|
2018-06-08 01:51:55 +00:00
|
|
|
const FormatSettings format_settings;
|
2017-04-01 07:20:54 +00:00
|
|
|
Block totals;
|
|
|
|
Block extremes;
|
2010-03-04 19:20:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|