be/src/format/table/hudi_reader.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | #pragma once |
18 | | #include <memory> |
19 | | #include <vector> |
20 | | |
21 | | #include "format/orc/vorc_reader.h" |
22 | | #include "format/parquet/vparquet_reader.h" |
23 | | #include "format/table/table_format_reader.h" |
24 | | namespace doris { |
25 | | class HudiReader : public TableFormatReader, public TableSchemaChangeHelper { |
26 | | public: |
27 | | HudiReader(std::unique_ptr<GenericReader> file_format_reader, RuntimeProfile* profile, |
28 | | RuntimeState* state, const TFileScanRangeParams& params, const TFileRangeDesc& range, |
29 | | io::IOContext* io_ctx, FileMetaCache* meta_cache) |
30 | 0 | : TableFormatReader(std::move(file_format_reader), state, profile, params, range, |
31 | 0 | io_ctx, meta_cache) {}; |
32 | | |
33 | 0 | ~HudiReader() override = default; |
34 | | |
35 | | Status get_next_block_inner(Block* block, size_t* read_rows, bool* eof) final; |
36 | | |
37 | 0 | Status init_row_filters() final { return Status::OK(); }; |
38 | | }; |
39 | | |
40 | | class HudiParquetReader final : public HudiReader { |
41 | | public: |
42 | | ENABLE_FACTORY_CREATOR(HudiParquetReader); |
43 | | HudiParquetReader(std::unique_ptr<GenericReader> file_format_reader, RuntimeProfile* profile, |
44 | | RuntimeState* state, const TFileScanRangeParams& params, |
45 | | const TFileRangeDesc& range, io::IOContext* io_ctx, FileMetaCache* meta_cache) |
46 | 0 | : HudiReader(std::move(file_format_reader), profile, state, params, range, io_ctx, |
47 | 0 | meta_cache) {}; |
48 | | ~HudiParquetReader() final = default; |
49 | | |
50 | | Status init_reader( |
51 | | const std::vector<std::string>& read_table_col_names, |
52 | | std::unordered_map<std::string, uint32_t>* col_name_to_block_idx, |
53 | | const VExprContextSPtrs& conjuncts, |
54 | | phmap::flat_hash_map<int, std::vector<std::shared_ptr<ColumnPredicate>>>& |
55 | | slot_id_to_predicates, |
56 | | const TupleDescriptor* tuple_descriptor, const RowDescriptor* row_descriptor, |
57 | | const std::unordered_map<std::string, int>* colname_to_slot_id, |
58 | | const VExprContextSPtrs* not_single_slot_filter_conjuncts, |
59 | | const std::unordered_map<int, VExprContextSPtrs>* slot_id_to_filter_conjuncts); |
60 | | }; |
61 | | |
62 | | class HudiOrcReader final : public HudiReader { |
63 | | public: |
64 | | ENABLE_FACTORY_CREATOR(HudiOrcReader); |
65 | | HudiOrcReader(std::unique_ptr<GenericReader> file_format_reader, RuntimeProfile* profile, |
66 | | RuntimeState* state, const TFileScanRangeParams& params, |
67 | | const TFileRangeDesc& range, io::IOContext* io_ctx, FileMetaCache* meta_cache) |
68 | 0 | : HudiReader(std::move(file_format_reader), profile, state, params, range, io_ctx, |
69 | 0 | meta_cache) {}; |
70 | | ~HudiOrcReader() final = default; |
71 | | |
72 | | Status init_reader( |
73 | | const std::vector<std::string>& read_table_col_names, |
74 | | std::unordered_map<std::string, uint32_t>* col_name_to_block_idx, |
75 | | const VExprContextSPtrs& conjuncts, const TupleDescriptor* tuple_descriptor, |
76 | | const RowDescriptor* row_descriptor, |
77 | | const VExprContextSPtrs* not_single_slot_filter_conjuncts, |
78 | 0 | const std::unordered_map<int, VExprContextSPtrs>* slot_id_to_filter_conjuncts) { |
79 | 0 | auto* orc_reader = static_cast<OrcReader*>(_file_format_reader.get()); |
80 | 0 | const orc::Type* orc_type_ptr = nullptr; |
81 | 0 | RETURN_IF_ERROR(orc_reader->get_file_type(&orc_type_ptr)); |
82 | 0 | RETURN_IF_ERROR(gen_table_info_node_by_field_id( |
83 | 0 | _params, _range.table_format_params.hudi_params.schema_id, tuple_descriptor, |
84 | 0 | orc_type_ptr)); |
85 | | |
86 | 0 | return orc_reader->init_reader(&read_table_col_names, col_name_to_block_idx, conjuncts, |
87 | 0 | false, tuple_descriptor, row_descriptor, |
88 | 0 | not_single_slot_filter_conjuncts, |
89 | 0 | slot_id_to_filter_conjuncts, table_info_node_ptr); |
90 | 0 | } |
91 | | }; |
92 | | |
93 | | } // namespace doris |