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 | | #include "common/compile_check_begin.h" |
26 | | class HudiReader : public TableFormatReader, public TableSchemaChangeHelper { |
27 | | public: |
28 | | HudiReader(std::unique_ptr<GenericReader> file_format_reader, RuntimeProfile* profile, |
29 | | RuntimeState* state, const TFileScanRangeParams& params, const TFileRangeDesc& range, |
30 | | io::IOContext* io_ctx, FileMetaCache* meta_cache) |
31 | 0 | : TableFormatReader(std::move(file_format_reader), state, profile, params, range, |
32 | 0 | io_ctx, meta_cache) {}; |
33 | | |
34 | 0 | ~HudiReader() override = default; |
35 | | |
36 | | Status get_next_block_inner(Block* block, size_t* read_rows, bool* eof) final; |
37 | | |
38 | 0 | Status init_row_filters() final { return Status::OK(); }; |
39 | | }; |
40 | | |
41 | | class HudiParquetReader final : public HudiReader { |
42 | | public: |
43 | | ENABLE_FACTORY_CREATOR(HudiParquetReader); |
44 | | HudiParquetReader(std::unique_ptr<GenericReader> file_format_reader, RuntimeProfile* profile, |
45 | | RuntimeState* state, const TFileScanRangeParams& params, |
46 | | const TFileRangeDesc& range, io::IOContext* io_ctx, FileMetaCache* meta_cache) |
47 | 0 | : HudiReader(std::move(file_format_reader), profile, state, params, range, io_ctx, |
48 | 0 | meta_cache) {}; |
49 | | ~HudiParquetReader() final = default; |
50 | | |
51 | | Status init_reader( |
52 | | const std::vector<std::string>& read_table_col_names, |
53 | | std::unordered_map<std::string, uint32_t>* col_name_to_block_idx, |
54 | | const VExprContextSPtrs& conjuncts, |
55 | | phmap::flat_hash_map<int, std::vector<std::shared_ptr<ColumnPredicate>>>& |
56 | | slot_id_to_predicates, |
57 | | const TupleDescriptor* tuple_descriptor, const RowDescriptor* row_descriptor, |
58 | | const std::unordered_map<std::string, int>* colname_to_slot_id, |
59 | | const VExprContextSPtrs* not_single_slot_filter_conjuncts, |
60 | | const std::unordered_map<int, VExprContextSPtrs>* slot_id_to_filter_conjuncts); |
61 | | }; |
62 | | |
63 | | class HudiOrcReader final : public HudiReader { |
64 | | public: |
65 | | ENABLE_FACTORY_CREATOR(HudiOrcReader); |
66 | | HudiOrcReader(std::unique_ptr<GenericReader> file_format_reader, RuntimeProfile* profile, |
67 | | RuntimeState* state, const TFileScanRangeParams& params, |
68 | | const TFileRangeDesc& range, io::IOContext* io_ctx, FileMetaCache* meta_cache) |
69 | 0 | : HudiReader(std::move(file_format_reader), profile, state, params, range, io_ctx, |
70 | 0 | meta_cache) {}; |
71 | | ~HudiOrcReader() final = default; |
72 | | |
73 | | Status init_reader( |
74 | | const std::vector<std::string>& read_table_col_names, |
75 | | std::unordered_map<std::string, uint32_t>* col_name_to_block_idx, |
76 | | const VExprContextSPtrs& conjuncts, const TupleDescriptor* tuple_descriptor, |
77 | | const RowDescriptor* row_descriptor, |
78 | | const VExprContextSPtrs* not_single_slot_filter_conjuncts, |
79 | 0 | const std::unordered_map<int, VExprContextSPtrs>* slot_id_to_filter_conjuncts) { |
80 | 0 | auto* orc_reader = static_cast<OrcReader*>(_file_format_reader.get()); |
81 | 0 | const orc::Type* orc_type_ptr = nullptr; |
82 | 0 | RETURN_IF_ERROR(orc_reader->get_file_type(&orc_type_ptr)); |
83 | 0 | RETURN_IF_ERROR(gen_table_info_node_by_field_id( |
84 | 0 | _params, _range.table_format_params.hudi_params.schema_id, tuple_descriptor, |
85 | 0 | orc_type_ptr)); |
86 | | |
87 | 0 | return orc_reader->init_reader(&read_table_col_names, col_name_to_block_idx, conjuncts, |
88 | 0 | false, tuple_descriptor, row_descriptor, |
89 | 0 | not_single_slot_filter_conjuncts, |
90 | 0 | slot_id_to_filter_conjuncts, table_info_node_ptr); |
91 | 0 | } |
92 | | }; |
93 | | |
94 | | #include "common/compile_check_end.h" |
95 | | } // namespace doris |