mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-11 19:10:50 +00:00
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
|
#pragma once
|
||
|
|
||
|
#include <string>
|
||
|
#include <Processors/IProcessor.h>
|
||
|
|
||
|
|
||
|
namespace DB
|
||
|
{
|
||
|
|
||
|
class WriteBuffer;
|
||
|
|
||
|
/** Output format have three inputs and no outputs. It writes data from WriteBuffer.
|
||
|
*
|
||
|
* First input is for main resultset, second is for "totals" and third is for "extremes".
|
||
|
* It's not necessarily to connect "totals" or "extremes" ports (they may remain dangling).
|
||
|
*
|
||
|
* Data from input ports are pulled in order: first, from main input, then totals, then extremes.
|
||
|
*
|
||
|
* By default, data for "totals" and "extremes" is ignored.
|
||
|
*/
|
||
|
class IOutputFormat : public IProcessor
|
||
|
{
|
||
|
public:
|
||
|
enum PortKind { Main = 0, Totals = 1, Extremes = 2 };
|
||
|
|
||
|
protected:
|
||
|
WriteBuffer & out;
|
||
|
|
||
|
Block current_block;
|
||
|
PortKind current_block_kind;
|
||
|
|
||
|
virtual void consume(Block) = 0;
|
||
|
virtual void consumeTotals(Block) {}
|
||
|
virtual void consumeExtremes(Block) {}
|
||
|
|
||
|
public:
|
||
|
IOutputFormat(Block header, WriteBuffer & out);
|
||
|
|
||
|
Status prepare() override;
|
||
|
void work() override;
|
||
|
|
||
|
void flush();
|
||
|
|
||
|
/** Content-Type to set when sending HTTP response.
|
||
|
*/
|
||
|
virtual std::string getContentType() const { return "text/plain; charset=UTF-8"; }
|
||
|
|
||
|
/// TODO onProgress, rows_before_limit_at_least
|
||
|
|
||
|
InputPort & getPort(PortKind kind) { return inputs[kind]; }
|
||
|
};
|
||
|
}
|
||
|
|