aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Processors/Formats/Impl/ArrowBlockOutputFormat.h
blob: 695ce97ba3bf77f696df215f3c158674f5f4ae94 (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
#pragma once
#include "clickhouse_config.h"

#if USE_ARROW

#include <Formats/FormatSettings.h>
#include <Processors/Formats/IOutputFormat.h>
#include "ArrowBufferedStreams.h"

namespace arrow { class Schema; }
namespace arrow::ipc { class RecordBatchWriter; }

namespace DB
{

class CHColumnToArrowColumn;

class ArrowBlockOutputFormat : public IOutputFormat
{
public:
    ArrowBlockOutputFormat(WriteBuffer & out_, const Block & header_, bool stream_, const FormatSettings & format_settings_);

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

    String getContentType() const override { return "application/octet-stream"; }

private:
    void consume(Chunk) override;
    void finalizeImpl() override;
    void resetFormatterImpl() override;

    void prepareWriter(const std::shared_ptr<arrow::Schema> & schema);

    bool stream;
    const FormatSettings format_settings;
    std::shared_ptr<ArrowBufferedOutputStream> arrow_ostream;
    std::shared_ptr<arrow::ipc::RecordBatchWriter> writer;
    std::unique_ptr<CHColumnToArrowColumn> ch_column_to_arrow_column;
};

}

#endif