ClickHouse/src/Processors/Formats/IRowOutputFormat.h

68 lines
2.2 KiB
C++
Raw Normal View History

#pragma once
#include <Formats/FormatFactory.h>
#include <Processors/Formats/IOutputFormat.h>
#include <string>
namespace DB
{
struct RowOutputFormatParams
{
using WriteCallback = std::function<void(const Columns & columns,size_t row)>;
// Callback used to indicate that another row is written.
WriteCallback callback;
};
class WriteBuffer;
/** Output format that writes data row by row.
*/
class IRowOutputFormat : public IOutputFormat
{
public:
using Params = RowOutputFormatParams;
protected:
2021-11-02 13:40:41 +00:00
IRowOutputFormat(const Block & header, WriteBuffer & out_, const Params & params_);
void consume(Chunk chunk) override;
void consumeTotals(Chunk chunk) override;
void consumeExtremes(Chunk chunk) override;
/** Write a row.
* Default implementation calls methods to write single values and delimiters
* (except delimiter between rows (writeRowBetweenDelimiter())).
*/
virtual void write(const Columns & columns, size_t row_num);
2019-02-19 18:41:18 +00:00
virtual void writeMinExtreme(const Columns & columns, size_t row_num);
virtual void writeMaxExtreme(const Columns & columns, size_t row_num);
virtual void writeTotals(const Columns & columns, size_t row_num);
/** Write single value. */
2021-03-09 14:46:52 +00:00
virtual void writeField(const IColumn & column, const ISerialization & serialization, size_t row_num) = 0;
/** Write delimiter. */
2019-02-19 18:41:18 +00:00
virtual void writeFieldDelimiter() {} /// delimiter between values
virtual void writeRowStartDelimiter() {} /// delimiter before each row
virtual void writeRowEndDelimiter() {} /// delimiter after each row
virtual void writeRowBetweenDelimiter() {} /// delimiter between rows
2021-11-02 13:40:41 +00:00
virtual void writePrefix() override {} /// delimiter before resultset
virtual void writeSuffix() override {} /// delimiter after resultset
2019-02-19 18:41:18 +00:00
virtual void writeBeforeTotals() {}
virtual void writeAfterTotals() {}
virtual void writeBeforeExtremes() {}
virtual void writeAfterExtremes() {}
virtual void finalizeImpl() override {} /// Write something after resultset, totals end extremes.
2019-02-19 18:41:18 +00:00
2021-11-02 13:40:41 +00:00
DataTypes types;
Serializations serializations;
Params params;
bool first_row = true;
};
}