be/src/format/table/paimon_cpp_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 | | |
18 | | #pragma once |
19 | | |
20 | | #include <cstddef> |
21 | | #include <map> |
22 | | #include <memory> |
23 | | #include <optional> |
24 | | #include <string> |
25 | | #include <unordered_map> |
26 | | #include <unordered_set> |
27 | | #include <vector> |
28 | | |
29 | | #include "cctz/time_zone.h" |
30 | | #include "common/status.h" |
31 | | #include "format/generic_reader.h" |
32 | | #include "paimon/reader/batch_reader.h" |
33 | | #include "paimon/table/source/split.h" |
34 | | #include "storage/olap_scan_common.h" |
35 | | |
36 | | namespace paimon { |
37 | | class TableRead; |
38 | | class Predicate; |
39 | | } // namespace paimon |
40 | | |
41 | | namespace doris { |
42 | | class RuntimeProfile; |
43 | | class RuntimeState; |
44 | | class SlotDescriptor; |
45 | | } // namespace doris |
46 | | |
47 | | namespace doris { |
48 | | #include "common/compile_check_begin.h" |
49 | | |
50 | | class Block; |
51 | | |
52 | | class PaimonCppReader : public GenericReader { |
53 | | ENABLE_FACTORY_CREATOR(PaimonCppReader); |
54 | | |
55 | | public: |
56 | | PaimonCppReader(const std::vector<SlotDescriptor*>& file_slot_descs, RuntimeState* state, |
57 | | RuntimeProfile* profile, const TFileRangeDesc& range, |
58 | | const TFileScanRangeParams* range_params); |
59 | | ~PaimonCppReader() override; |
60 | | |
61 | | Status init_reader(); |
62 | | Status get_next_block(Block* block, size_t* read_rows, bool* eof) override; |
63 | | Status get_columns(std::unordered_map<std::string, DataTypePtr>* name_to_type, |
64 | | std::unordered_set<std::string>* missing_cols) override; |
65 | | Status close() override; |
66 | 0 | void set_predicate(std::shared_ptr<paimon::Predicate> predicate) { |
67 | 0 | _predicate = std::move(predicate); |
68 | 0 | } |
69 | | |
70 | | private: |
71 | | Status _init_paimon_reader(); |
72 | | Status _decode_split(std::shared_ptr<paimon::Split>* split); |
73 | | // Resolve paimon table root path for schema/manifest lookup. |
74 | | std::optional<std::string> _resolve_table_path() const; |
75 | | std::vector<std::string> _build_read_columns() const; |
76 | | std::map<std::string, std::string> _build_options() const; |
77 | | |
78 | | const std::vector<SlotDescriptor*>& _file_slot_descs; |
79 | | RuntimeState* _state = nullptr; |
80 | | [[maybe_unused]] RuntimeProfile* _profile = nullptr; |
81 | | const TFileRangeDesc& _range; |
82 | | const TFileScanRangeParams* _range_params = nullptr; |
83 | | |
84 | | std::shared_ptr<paimon::Split> _split; |
85 | | std::unique_ptr<paimon::TableRead> _table_read; |
86 | | std::unique_ptr<paimon::BatchReader> _batch_reader; |
87 | | std::shared_ptr<paimon::Predicate> _predicate; |
88 | | |
89 | | std::unordered_map<std::string, uint32_t> _col_name_to_block_idx; |
90 | | int64_t _remaining_table_level_row_count = -1; |
91 | | cctz::time_zone _ctzz; |
92 | | }; |
93 | | |
94 | | #include "common/compile_check_end.h" |
95 | | } // namespace doris |