be/src/format/table/paimon_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 <gen_cpp/PlanNodes_types.h> |
21 | | |
22 | | #include <memory> |
23 | | #include <string> |
24 | | #include <utility> |
25 | | #include <vector> |
26 | | |
27 | | #include "common/status.h" |
28 | | #include "format/orc/vorc_reader.h" |
29 | | #include "format/parquet/vparquet_reader.h" |
30 | | #include "format/table/deletion_vector.h" |
31 | | #include "format/table/table_schema_change_helper.h" |
32 | | |
33 | | namespace doris { |
34 | | class ShardedKVCache; |
35 | | |
36 | | std::string build_paimon_deletion_vector_cache_key(const TPaimonDeletionFileDesc& deletion_file); |
37 | | |
38 | | Status decode_paimon_deletion_vector_buffer(const char* buf, size_t buffer_size, |
39 | | DeletionVector* deletion_vector); |
40 | | |
41 | | // PaimonOrcReader: directly inherits OrcReader (no composition wrapping). |
42 | | // Schema mapping in on_before_init_reader, deletion vector reading in on_after_init_reader. |
43 | | class PaimonOrcReader final : public OrcReader, public TableSchemaChangeHelper { |
44 | | public: |
45 | | ENABLE_FACTORY_CREATOR(PaimonOrcReader); |
46 | | PaimonOrcReader(RuntimeProfile* profile, RuntimeState* state, |
47 | | const TFileScanRangeParams& params, const TFileRangeDesc& range, |
48 | | size_t batch_size, const std::string& ctz, ShardedKVCache* kv_cache, |
49 | | io::IOContext* io_ctx, FileMetaCache* meta_cache = nullptr, |
50 | | bool enable_lazy_mat = true) |
51 | | : OrcReader(profile, state, params, range, batch_size, ctz, io_ctx, meta_cache, |
52 | | enable_lazy_mat), |
53 | | _kv_cache(kv_cache) { |
54 | | _init_paimon_profile(); |
55 | | } |
56 | | PaimonOrcReader(RuntimeProfile* profile, RuntimeState* state, |
57 | | const TFileScanRangeParams& params, const TFileRangeDesc& range, |
58 | | size_t batch_size, const std::string& ctz, ShardedKVCache* kv_cache, |
59 | | std::shared_ptr<io::IOContext> io_ctx_holder, |
60 | | FileMetaCache* meta_cache = nullptr, bool enable_lazy_mat = true) |
61 | 0 | : OrcReader(profile, state, params, range, batch_size, ctz, std::move(io_ctx_holder), |
62 | 0 | meta_cache, enable_lazy_mat), |
63 | 0 | _kv_cache(kv_cache) { |
64 | 0 | _init_paimon_profile(); |
65 | 0 | } |
66 | 1 | ~PaimonOrcReader() final = default; |
67 | | |
68 | | Status TEST_init_deletion_vector() { return _init_deletion_vector(); } |
69 | | |
70 | | protected: |
71 | | Status on_before_init_reader(ReaderInitContext* ctx) override; |
72 | | |
73 | | Status on_after_init_reader(ReaderInitContext* /*ctx*/) override; |
74 | | |
75 | | private: |
76 | | void _init_paimon_profile(); |
77 | | Status _init_deletion_vector(); |
78 | | |
79 | | struct PaimonProfile { |
80 | | RuntimeProfile::Counter* num_delete_rows = nullptr; |
81 | | RuntimeProfile::Counter* delete_files_read_time = nullptr; |
82 | | RuntimeProfile::Counter* parse_deletion_vector_time = nullptr; |
83 | | RuntimeProfile::Counter* decoded_cache_hit_count = nullptr; |
84 | | RuntimeProfile::Counter* decoded_cache_miss_count = nullptr; |
85 | | RuntimeProfile::Counter* file_cache_hit_count = nullptr; |
86 | | RuntimeProfile::Counter* file_cache_miss_count = nullptr; |
87 | | RuntimeProfile::Counter* file_cache_peer_read_count = nullptr; |
88 | | }; |
89 | | |
90 | | const DeletionVector* _deletion_vector = nullptr; |
91 | | ShardedKVCache* _kv_cache; |
92 | | PaimonProfile _paimon_profile; |
93 | | }; |
94 | | |
95 | | // PaimonParquetReader: directly inherits ParquetReader (no composition wrapping). |
96 | | class PaimonParquetReader final : public ParquetReader, public TableSchemaChangeHelper { |
97 | | public: |
98 | | ENABLE_FACTORY_CREATOR(PaimonParquetReader); |
99 | | PaimonParquetReader(RuntimeProfile* profile, const TFileScanRangeParams& params, |
100 | | const TFileRangeDesc& range, size_t batch_size, const cctz::time_zone* ctz, |
101 | | ShardedKVCache* kv_cache, io::IOContext* io_ctx, RuntimeState* state, |
102 | | FileMetaCache* meta_cache = nullptr, bool enable_lazy_mat = true) |
103 | | : ParquetReader(profile, params, range, batch_size, ctz, io_ctx, state, meta_cache, |
104 | | enable_lazy_mat), |
105 | | _kv_cache(kv_cache) { |
106 | | _init_paimon_profile(); |
107 | | } |
108 | | PaimonParquetReader(RuntimeProfile* profile, const TFileScanRangeParams& params, |
109 | | const TFileRangeDesc& range, size_t batch_size, const cctz::time_zone* ctz, |
110 | | ShardedKVCache* kv_cache, std::shared_ptr<io::IOContext> io_ctx_holder, |
111 | | RuntimeState* state, FileMetaCache* meta_cache = nullptr, |
112 | | bool enable_lazy_mat = true) |
113 | 0 | : ParquetReader(profile, params, range, batch_size, ctz, std::move(io_ctx_holder), |
114 | 0 | state, meta_cache, enable_lazy_mat), |
115 | 0 | _kv_cache(kv_cache) { |
116 | 0 | _init_paimon_profile(); |
117 | 0 | } |
118 | 1 | ~PaimonParquetReader() final = default; |
119 | | |
120 | | Status TEST_init_deletion_vector() { return _init_deletion_vector(); } |
121 | | |
122 | | protected: |
123 | | Status on_before_init_reader(ReaderInitContext* ctx) override; |
124 | | |
125 | | Status on_after_init_reader(ReaderInitContext* /*ctx*/) override; |
126 | | |
127 | | private: |
128 | | void _init_paimon_profile(); |
129 | | Status _init_deletion_vector(); |
130 | | |
131 | | struct PaimonProfile { |
132 | | RuntimeProfile::Counter* num_delete_rows = nullptr; |
133 | | RuntimeProfile::Counter* delete_files_read_time = nullptr; |
134 | | RuntimeProfile::Counter* parse_deletion_vector_time = nullptr; |
135 | | RuntimeProfile::Counter* decoded_cache_hit_count = nullptr; |
136 | | RuntimeProfile::Counter* decoded_cache_miss_count = nullptr; |
137 | | RuntimeProfile::Counter* file_cache_hit_count = nullptr; |
138 | | RuntimeProfile::Counter* file_cache_miss_count = nullptr; |
139 | | RuntimeProfile::Counter* file_cache_peer_read_count = nullptr; |
140 | | }; |
141 | | |
142 | | const DeletionVector* _deletion_vector = nullptr; |
143 | | ShardedKVCache* _kv_cache; |
144 | | PaimonProfile _paimon_profile; |
145 | | }; |
146 | | |
147 | | } // namespace doris |