aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Processors/Formats/PullingOutputFormat.h
blob: a8efb8dd962abdd3bb7a6159102b82ad34007718 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <Processors/Formats/IOutputFormat.h>
#include <QueryPipeline/ProfileInfo.h>

namespace DB
{

class WriteBufferFromPointer;

/// Output format which is used in PullingPipelineExecutor.
class PullingOutputFormat : public IOutputFormat
{
public:
    PullingOutputFormat(const Block & header, std::atomic_bool & consume_data_flag_);

    String getName() const override { return "PullingOutputFormat"; }

    Chunk getChunk();
    Chunk getTotals();
    Chunk getExtremes();

    ProfileInfo & getProfileInfo() { return info; }

    void setRowsBeforeLimit(size_t rows_before_limit) override;

    bool expectMaterializedColumns() const override { return false; }

protected:
    void consume(Chunk chunk) override;
    void consumeTotals(Chunk chunk) override { totals = std::move(chunk); }
    void consumeExtremes(Chunk chunk) override { extremes = std::move(chunk); }

private:
    Chunk data;
    Chunk totals;
    Chunk extremes;

    std::atomic_bool & has_data_flag;

    ProfileInfo info;

    /// Is not used.
    static WriteBufferFromPointer out;
};

}