2020-04-28 19:52:22 +00:00
|
|
|
#pragma once
|
2021-07-28 11:09:17 +00:00
|
|
|
#if !defined(ARCADIA_BUILD)
|
|
|
|
# include "config_formats.h"
|
|
|
|
#endif
|
|
|
|
|
2020-05-03 01:01:05 +00:00
|
|
|
#if USE_ARROW
|
2020-04-28 19:52:22 +00:00
|
|
|
|
|
|
|
#include <Processors/Formats/IInputFormat.h>
|
2021-07-01 17:59:28 +00:00
|
|
|
#include <Formats/FormatSettings.h>
|
2020-04-28 19:52:22 +00:00
|
|
|
|
2020-05-21 04:07:47 +00:00
|
|
|
namespace arrow { class RecordBatchReader; }
|
2020-05-04 14:28:36 +00:00
|
|
|
namespace arrow::ipc { class RecordBatchFileReader; }
|
2020-04-28 19:52:22 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-05-02 19:35:58 +00:00
|
|
|
class ReadBuffer;
|
2021-06-02 08:51:07 +00:00
|
|
|
class ArrowColumnToCHColumn;
|
2020-05-02 19:35:58 +00:00
|
|
|
|
2020-05-02 19:34:34 +00:00
|
|
|
class ArrowBlockInputFormat : public IInputFormat
|
2020-04-28 19:52:22 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-07-01 17:59:28 +00:00
|
|
|
ArrowBlockInputFormat(ReadBuffer & in_, const Block & header_, bool stream_, const FormatSettings & format_settings_);
|
2020-04-28 19:52:22 +00:00
|
|
|
|
|
|
|
void resetParser() override;
|
|
|
|
|
|
|
|
String getName() const override { return "ArrowBlockInputFormat"; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Chunk generate() override;
|
|
|
|
|
|
|
|
private:
|
2020-05-25 02:50:55 +00:00
|
|
|
// Whether to use ArrowStream format
|
2020-05-21 04:07:47 +00:00
|
|
|
bool stream;
|
2020-05-25 02:50:55 +00:00
|
|
|
// This field is only used for ArrowStream format
|
2020-05-21 04:07:47 +00:00
|
|
|
std::shared_ptr<arrow::RecordBatchReader> stream_reader;
|
2020-05-25 02:50:55 +00:00
|
|
|
// The following fields are used only for Arrow format
|
2020-05-04 14:28:36 +00:00
|
|
|
std::shared_ptr<arrow::ipc::RecordBatchFileReader> file_reader;
|
2020-05-25 02:50:55 +00:00
|
|
|
|
2021-06-02 08:51:07 +00:00
|
|
|
std::unique_ptr<ArrowColumnToCHColumn> arrow_column_to_ch_column;
|
2021-05-25 12:01:28 +00:00
|
|
|
|
2020-05-04 14:28:36 +00:00
|
|
|
int record_batch_total = 0;
|
|
|
|
int record_batch_current = 0;
|
2020-05-21 04:07:47 +00:00
|
|
|
|
2021-07-01 17:59:28 +00:00
|
|
|
const FormatSettings format_settings;
|
|
|
|
|
2020-05-21 04:07:47 +00:00
|
|
|
void prepareReader();
|
2020-04-28 19:52:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-02 19:32:33 +00:00
|
|
|
#endif
|