ClickHouse/src/Processors/Formats/Impl/ParquetBlockInputFormat.h

67 lines
1.5 KiB
C++
Raw Normal View History

#pragma once
2021-10-27 23:10:39 +00:00
#include "config_formats.h"
#if USE_PARQUET
2019-08-02 16:00:24 +00:00
#include <Processors/Formats/IInputFormat.h>
#include <Processors/Formats/ISchemaReader.h>
#include <Formats/FormatSettings.h>
2020-05-05 12:56:54 +00:00
namespace parquet::arrow { class FileReader; }
2022-03-11 09:26:13 +00:00
namespace arrow { class Buffer; }
namespace DB
{
2021-06-02 08:51:07 +00:00
class ArrowColumnToCHColumn;
2020-05-05 12:56:54 +00:00
class ParquetBlockInputFormat : public IInputFormat
{
public:
ParquetBlockInputFormat(ReadBuffer & in_, Block header_, const FormatSettings & format_settings_);
void resetParser() override;
String getName() const override { return "ParquetBlockInputFormat"; }
const BlockMissingValues & getMissingValues() const override;
2021-11-02 13:40:41 +00:00
private:
Chunk generate() override;
void prepareReader();
2021-12-27 19:42:56 +00:00
void onCancel() override
{
is_stopped = 1;
}
std::unique_ptr<parquet::arrow::FileReader> file_reader;
int row_group_total = 0;
int row_group_current = 0;
// indices of columns to read from Parquet file
std::vector<int> column_indices;
2021-06-02 08:51:07 +00:00
std::unique_ptr<ArrowColumnToCHColumn> arrow_column_to_ch_column;
2021-12-02 08:14:25 +00:00
std::vector<size_t> missing_columns;
BlockMissingValues block_missing_values;
const FormatSettings format_settings;
const std::unordered_set<int> & skip_row_groups;
2021-12-27 19:42:56 +00:00
std::atomic<int> is_stopped{0};
};
class ParquetSchemaReader : public ISchemaReader
{
public:
ParquetSchemaReader(ReadBuffer & in_, const FormatSettings & format_settings_);
NamesAndTypesList readSchema() override;
private:
const FormatSettings format_settings;
};
}
#endif