be/src/format_v2/table_reader.cpp
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 | | #include "format_v2/table_reader.h" |
19 | | |
20 | | #include <gen_cpp/ExternalTableSchema_types.h> |
21 | | #include <gen_cpp/PlanNodes_types.h> |
22 | | #include <gen_cpp/Types_types.h> |
23 | | |
24 | | #include <algorithm> |
25 | | #include <memory> |
26 | | #include <ranges> |
27 | | #include <set> |
28 | | #include <sstream> |
29 | | #include <utility> |
30 | | #include <vector> |
31 | | |
32 | | #include "common/cast_set.h" |
33 | | #include "common/status.h" |
34 | | #include "core/assert_cast.h" |
35 | | #include "core/data_type/data_type_array.h" |
36 | | #include "core/data_type/data_type_map.h" |
37 | | #include "core/data_type/data_type_struct.h" |
38 | | #include "exprs/vexpr_context.h" |
39 | | #include "exprs/vslot_ref.h" |
40 | | #include "format/table/deletion_vector_reader.h" |
41 | | #include "format/table/iceberg_delete_file_reader_helper.h" |
42 | | #include "format/table/paimon_reader.h" |
43 | | #include "format_v2/column_mapper.h" |
44 | | #include "format_v2/delimited_text/csv_reader.h" |
45 | | #include "format_v2/delimited_text/text_reader.h" |
46 | | #include "format_v2/json/json_reader.h" |
47 | | #include "format_v2/native/native_reader.h" |
48 | | #include "format_v2/parquet/parquet_reader.h" |
49 | | #include "storage/segment/condition_cache.h" |
50 | | #include "util/debug_points.h" |
51 | | #include "util/string_util.h" |
52 | | |
53 | | namespace doris::format { |
54 | | namespace { |
55 | | |
56 | | template <typename T, typename Formatter> |
57 | 61 | std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) { |
58 | 61 | std::ostringstream out; |
59 | 61 | out << "["; |
60 | 70 | for (size_t i = 0; i < values.size(); ++i) { |
61 | 9 | if (i > 0) { |
62 | 3 | out << ", "; |
63 | 3 | } |
64 | 9 | out << formatter(values[i]); |
65 | 9 | } |
66 | 61 | out << "]"; |
67 | 61 | return out.str(); |
68 | 61 | } table_reader.cpp:_ZN5doris6format12_GLOBAL__N_131join_table_reader_debug_stringsINS0_16ColumnDefinitionEZNKS0_11TableReader12debug_stringB5cxx11EvE3$_0EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISD_EET0_ Line | Count | Source | 57 | 12 | std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) { | 58 | 12 | std::ostringstream out; | 59 | 12 | out << "["; | 60 | 14 | for (size_t i = 0; i < values.size(); ++i) { | 61 | 2 | if (i > 0) { | 62 | 1 | out << ", "; | 63 | 1 | } | 64 | 2 | out << formatter(values[i]); | 65 | 2 | } | 66 | 12 | out << "]"; | 67 | 12 | return out.str(); | 68 | 12 | } |
table_reader.cpp:_ZN5doris6format12_GLOBAL__N_131join_table_reader_debug_stringsINS0_11TableFilterEZNKS0_11TableReader12debug_stringB5cxx11EvE3$_1EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISD_EET0_ Line | Count | Source | 57 | 12 | std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) { | 58 | 12 | std::ostringstream out; | 59 | 12 | out << "["; | 60 | 13 | for (size_t i = 0; i < values.size(); ++i) { | 61 | 1 | if (i > 0) { | 62 | 0 | out << ", "; | 63 | 0 | } | 64 | 1 | out << formatter(values[i]); | 65 | 1 | } | 66 | 12 | out << "]"; | 67 | 12 | return out.str(); | 68 | 12 | } |
table_reader.cpp:_ZN5doris6format12_GLOBAL__N_131join_table_reader_debug_stringsINS0_11GlobalIndexEZNS1_25table_filter_debug_stringB5cxx11ERKNS0_11TableFilterEE3$_0EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISF_EET0_ Line | Count | Source | 57 | 1 | std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) { | 58 | 1 | std::ostringstream out; | 59 | 1 | out << "["; | 60 | 2 | for (size_t i = 0; i < values.size(); ++i) { | 61 | 1 | if (i > 0) { | 62 | 0 | out << ", "; | 63 | 0 | } | 64 | 1 | out << formatter(values[i]); | 65 | 1 | } | 66 | 1 | out << "]"; | 67 | 1 | return out.str(); | 68 | 1 | } |
table_reader.cpp:_ZN5doris6format12_GLOBAL__N_131join_table_reader_debug_stringsISt10shared_ptrINS_12VExprContextEEZNKS0_11TableReader12debug_stringB5cxx11EvE3$_2EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISF_EET0_ Line | Count | Source | 57 | 12 | std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) { | 58 | 12 | std::ostringstream out; | 59 | 12 | out << "["; | 60 | 13 | for (size_t i = 0; i < values.size(); ++i) { | 61 | 1 | if (i > 0) { | 62 | 0 | out << ", "; | 63 | 0 | } | 64 | 1 | out << formatter(values[i]); | 65 | 1 | } | 66 | 12 | out << "]"; | 67 | 12 | return out.str(); | 68 | 12 | } |
table_reader.cpp:_ZN5doris6format12_GLOBAL__N_131join_table_reader_debug_stringsINS0_16ColumnDefinitionEZNKS0_11TableReader12debug_stringB5cxx11EvE3$_3EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISD_EET0_ Line | Count | Source | 57 | 12 | std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) { | 58 | 12 | std::ostringstream out; | 59 | 12 | out << "["; | 60 | 14 | for (size_t i = 0; i < values.size(); ++i) { | 61 | 2 | if (i > 0) { | 62 | 1 | out << ", "; | 63 | 1 | } | 64 | 2 | out << formatter(values[i]); | 65 | 2 | } | 66 | 12 | out << "]"; | 67 | 12 | return out.str(); | 68 | 12 | } |
table_reader.cpp:_ZN5doris6format12_GLOBAL__N_131join_table_reader_debug_stringsINS0_11TableReader15FileBlockColumnEZNKS3_12debug_stringB5cxx11EvE3$_4EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISD_EET0_ Line | Count | Source | 57 | 12 | std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) { | 58 | 12 | std::ostringstream out; | 59 | 12 | out << "["; | 60 | 14 | for (size_t i = 0; i < values.size(); ++i) { | 61 | 2 | if (i > 0) { | 62 | 1 | out << ", "; | 63 | 1 | } | 64 | 2 | out << formatter(values[i]); | 65 | 2 | } | 66 | 12 | out << "]"; | 67 | 12 | return out.str(); | 68 | 12 | } |
|
69 | | |
70 | 12 | std::string file_format_to_string(FileFormat format) { |
71 | 12 | switch (format) { |
72 | 5 | case FileFormat::PARQUET: |
73 | 5 | return "PARQUET"; |
74 | 1 | case FileFormat::ORC: |
75 | 1 | return "ORC"; |
76 | 1 | case FileFormat::CSV: |
77 | 1 | return "CSV"; |
78 | 1 | case FileFormat::JSON: |
79 | 1 | return "JSON"; |
80 | 1 | case FileFormat::TEXT: |
81 | 1 | return "TEXT"; |
82 | 1 | case FileFormat::JNI: |
83 | 1 | return "JNI"; |
84 | 1 | case FileFormat::NATIVE: |
85 | 1 | return "NATIVE"; |
86 | 1 | case FileFormat::ARROW: |
87 | 1 | return "ARROW"; |
88 | 12 | } |
89 | 0 | return "UNKNOWN"; |
90 | 12 | } |
91 | | |
92 | 12 | std::string push_down_agg_to_string(TPushAggOp::type op) { |
93 | 12 | switch (op) { |
94 | 8 | case TPushAggOp::NONE: |
95 | 8 | return "NONE"; |
96 | 1 | case TPushAggOp::COUNT: |
97 | 1 | return "COUNT"; |
98 | 1 | case TPushAggOp::MINMAX: |
99 | 1 | return "MINMAX"; |
100 | 1 | case TPushAggOp::MIX: |
101 | 1 | return "MIX"; |
102 | 1 | case TPushAggOp::COUNT_ON_INDEX: |
103 | 1 | return "COUNT_ON_INDEX"; |
104 | 12 | } |
105 | 0 | return "UNKNOWN"; |
106 | 12 | } |
107 | | |
108 | 12 | std::string current_file_debug_string(const std::unique_ptr<ScanTask>& task) { |
109 | 12 | if (task == nullptr || task->data_file == nullptr) { |
110 | 11 | return "null"; |
111 | 11 | } |
112 | 1 | const auto& file = *task->data_file; |
113 | 1 | std::ostringstream out; |
114 | 1 | out << "FileDescription{path=" << file.path << ", file_size=" << file.file_size |
115 | 1 | << ", range_start_offset=" << file.range_start_offset << ", range_size=" << file.range_size |
116 | 1 | << ", mtime=" << file.mtime << ", fs_name=" << file.fs_name |
117 | 1 | << ", file_cache_admission=" << file.file_cache_admission << "}"; |
118 | 1 | return out.str(); |
119 | 12 | } |
120 | | |
121 | 12 | std::string partition_values_debug_string(const std::map<std::string, Field>& partition_values) { |
122 | 12 | std::ostringstream out; |
123 | 12 | out << "{"; |
124 | 12 | size_t idx = 0; |
125 | 12 | for (const auto& [key, _] : partition_values) { |
126 | 1 | if (idx++ > 0) { |
127 | 0 | out << ", "; |
128 | 0 | } |
129 | 1 | out << key; |
130 | 1 | } |
131 | 12 | out << "}"; |
132 | 12 | return out.str(); |
133 | 12 | } |
134 | | |
135 | 6 | const schema::external::TField* get_field_ptr(const schema::external::TFieldPtr& field_ptr) { |
136 | 6 | if (!field_ptr.__isset.field_ptr || field_ptr.field_ptr == nullptr) { |
137 | 0 | return nullptr; |
138 | 0 | } |
139 | 6 | return field_ptr.field_ptr.get(); |
140 | 6 | } |
141 | | |
142 | 4 | bool external_field_matches_name(const schema::external::TField& field, const std::string& name) { |
143 | 4 | if (field.__isset.name && to_lower(field.name) == to_lower(name)) { |
144 | 0 | return true; |
145 | 0 | } |
146 | 4 | return field.__isset.name_mapping && |
147 | 4 | std::ranges::any_of(field.name_mapping, [&](const std::string& alias) { |
148 | 4 | return to_lower(alias) == to_lower(name); |
149 | 4 | }); |
150 | 4 | } |
151 | | |
152 | | DataTypePtr find_struct_child_type_by_external_field(const DataTypeStruct& struct_type, |
153 | 2 | const schema::external::TField& field) { |
154 | 3 | for (size_t field_idx = 0; field_idx < struct_type.get_elements().size(); ++field_idx) { |
155 | 3 | if (external_field_matches_name(field, struct_type.get_element_name(field_idx))) { |
156 | 2 | return struct_type.get_element(field_idx); |
157 | 2 | } |
158 | 3 | } |
159 | 0 | return nullptr; |
160 | 2 | } |
161 | | |
162 | | ColumnDefinition build_schema_column_from_external_field(const schema::external::TField& field, |
163 | 6 | DataTypePtr type) { |
164 | 6 | ColumnDefinition column { |
165 | 6 | .identifier = field.__isset.id ? Field::create_field<TYPE_INT>(field.id) : Field {}, |
166 | 6 | .name = field.__isset.name ? field.name : "", |
167 | 6 | .name_mapping = |
168 | 6 | field.__isset.name_mapping ? field.name_mapping : std::vector<std::string> {}, |
169 | 6 | .type = std::move(type), |
170 | 6 | .children = {}, |
171 | 6 | .default_expr = nullptr, |
172 | 6 | .is_partition_key = false, |
173 | 6 | }; |
174 | 6 | if (column.type == nullptr || !field.__isset.nestedField) { |
175 | 3 | return column; |
176 | 3 | } |
177 | | |
178 | 3 | const auto nested_type = remove_nullable(column.type); |
179 | 3 | switch (nested_type->get_primitive_type()) { |
180 | 1 | case TYPE_STRUCT: { |
181 | 1 | if (!field.nestedField.__isset.struct_field || |
182 | 1 | !field.nestedField.struct_field.__isset.fields) { |
183 | 0 | return column; |
184 | 0 | } |
185 | 1 | const auto& struct_type = assert_cast<const DataTypeStruct&>(*nested_type); |
186 | 2 | for (const auto& child_ptr : field.nestedField.struct_field.fields) { |
187 | 2 | const auto* child_field = get_field_ptr(child_ptr); |
188 | 2 | if (child_field == nullptr || !child_field->__isset.name) { |
189 | 0 | continue; |
190 | 0 | } |
191 | 2 | auto child_type = find_struct_child_type_by_external_field(struct_type, *child_field); |
192 | 2 | if (child_type == nullptr) { |
193 | 0 | continue; |
194 | 0 | } |
195 | 2 | column.children.push_back( |
196 | 2 | build_schema_column_from_external_field(*child_field, child_type)); |
197 | 2 | } |
198 | 1 | break; |
199 | 1 | } |
200 | 1 | case TYPE_ARRAY: { |
201 | 1 | if (!field.nestedField.__isset.array_field || |
202 | 1 | !field.nestedField.array_field.__isset.item_field) { |
203 | 0 | return column; |
204 | 0 | } |
205 | 1 | const auto* item_field = get_field_ptr(field.nestedField.array_field.item_field); |
206 | 1 | if (item_field == nullptr) { |
207 | 0 | return column; |
208 | 0 | } |
209 | 1 | const auto& array_type = assert_cast<const DataTypeArray&>(*nested_type); |
210 | 1 | auto child = |
211 | 1 | build_schema_column_from_external_field(*item_field, array_type.get_nested_type()); |
212 | 1 | child.name = "element"; |
213 | 1 | if (child.has_identifier_name()) { |
214 | 0 | child.identifier = Field::create_field<TYPE_STRING>(child.name); |
215 | 0 | } |
216 | 1 | column.children.push_back(std::move(child)); |
217 | 1 | break; |
218 | 1 | } |
219 | 1 | case TYPE_MAP: { |
220 | 1 | if (!field.nestedField.__isset.map_field || |
221 | 1 | !field.nestedField.map_field.__isset.key_field || |
222 | 1 | !field.nestedField.map_field.__isset.value_field) { |
223 | 0 | return column; |
224 | 0 | } |
225 | 1 | const auto& map_type = assert_cast<const DataTypeMap&>(*nested_type); |
226 | 1 | const auto* key_field = get_field_ptr(field.nestedField.map_field.key_field); |
227 | 1 | if (key_field != nullptr) { |
228 | 1 | auto child = |
229 | 1 | build_schema_column_from_external_field(*key_field, map_type.get_key_type()); |
230 | 1 | child.name = "key"; |
231 | 1 | if (child.has_identifier_name()) { |
232 | 0 | child.identifier = Field::create_field<TYPE_STRING>(child.name); |
233 | 0 | } |
234 | 1 | column.children.push_back(std::move(child)); |
235 | 1 | } |
236 | 1 | const auto* value_field = get_field_ptr(field.nestedField.map_field.value_field); |
237 | 1 | if (value_field != nullptr) { |
238 | 1 | auto child = build_schema_column_from_external_field(*value_field, |
239 | 1 | map_type.get_value_type()); |
240 | 1 | child.name = "value"; |
241 | 1 | if (child.has_identifier_name()) { |
242 | 0 | child.identifier = Field::create_field<TYPE_STRING>(child.name); |
243 | 0 | } |
244 | 1 | column.children.push_back(std::move(child)); |
245 | 1 | } |
246 | 1 | break; |
247 | 1 | } |
248 | 0 | default: |
249 | 0 | break; |
250 | 3 | } |
251 | 3 | return column; |
252 | 3 | } |
253 | | |
254 | | const schema::external::TField* find_external_root_field(const TFileScanRangeParams* params, |
255 | 7 | const ColumnDefinition& column) { |
256 | 7 | if (params == nullptr || !params->__isset.history_schema_info || |
257 | 7 | params->history_schema_info.empty()) { |
258 | 6 | return nullptr; |
259 | 6 | } |
260 | 1 | const auto* schema = ¶ms->history_schema_info.front(); |
261 | 1 | if (params->__isset.current_schema_id) { |
262 | 2 | for (const auto& candidate_schema : params->history_schema_info) { |
263 | 2 | if (candidate_schema.__isset.schema_id && |
264 | 2 | candidate_schema.schema_id == params->current_schema_id) { |
265 | 1 | schema = &candidate_schema; |
266 | 1 | break; |
267 | 1 | } |
268 | 2 | } |
269 | 1 | } |
270 | 1 | if (!schema->__isset.root_field || !schema->root_field.__isset.fields) { |
271 | 0 | return nullptr; |
272 | 0 | } |
273 | 1 | for (const auto& field_ptr : schema->root_field.fields) { |
274 | 1 | const auto* field = get_field_ptr(field_ptr); |
275 | 1 | if (field == nullptr) { |
276 | 0 | continue; |
277 | 0 | } |
278 | 1 | if (external_field_matches_name(*field, column.name)) { |
279 | 1 | return field; |
280 | 1 | } |
281 | 1 | } |
282 | 0 | return nullptr; |
283 | 1 | } |
284 | | |
285 | 2 | std::string expr_context_debug_string(const VExprContextSPtr& context) { |
286 | 2 | if (context == nullptr) { |
287 | 0 | return "null"; |
288 | 0 | } |
289 | 2 | const auto root = context->root(); |
290 | 2 | if (root == nullptr) { |
291 | 0 | return "VExprContext{root=null}"; |
292 | 0 | } |
293 | 2 | std::ostringstream out; |
294 | 2 | out << "VExprContext{root_name=" << root->expr_name() << ", root_debug=" << root->debug_string() |
295 | 2 | << "}"; |
296 | 2 | return out.str(); |
297 | 2 | } |
298 | | |
299 | 1 | std::string table_filter_debug_string(const TableFilter& filter) { |
300 | 1 | std::ostringstream out; |
301 | 1 | out << "TableFilter{conjunct=" << expr_context_debug_string(filter.conjunct) |
302 | 1 | << ", global_indices=" |
303 | 1 | << join_table_reader_debug_strings( |
304 | 1 | filter.global_indices, |
305 | 1 | [](GlobalIndex global_index) { return std::to_string(global_index.value()); }) |
306 | 1 | << "}"; |
307 | 1 | return out.str(); |
308 | 1 | } |
309 | | |
310 | 3 | bool contains_runtime_filter(const VExprContextSPtrs& conjuncts) { |
311 | 3 | return std::ranges::any_of(conjuncts, [](const auto& conjunct) { |
312 | 3 | return conjunct != nullptr && conjunct->root() != nullptr && |
313 | 3 | conjunct->root()->is_rf_wrapper(); |
314 | 3 | }); |
315 | 3 | } |
316 | | |
317 | 79 | void collect_global_indices(const VExprSPtr& expr, std::set<GlobalIndex>* global_indices) { |
318 | 79 | if (expr == nullptr) { |
319 | 0 | return; |
320 | 0 | } |
321 | 79 | if (expr->is_rf_wrapper()) { |
322 | | // RuntimeFilterExpr wraps a real predicate expression but its own thrift node can still |
323 | | // look like SLOT_REF. Collect indices from the wrapped predicate; do not cast the wrapper |
324 | | // itself to VSlotRef. |
325 | 2 | collect_global_indices(expr->get_impl(), global_indices); |
326 | 2 | return; |
327 | 2 | } |
328 | 77 | if (expr->is_slot_ref()) { |
329 | 26 | const auto* slot_ref = assert_cast<const VSlotRef*>(expr.get()); |
330 | 26 | DORIS_CHECK(slot_ref->column_id() >= 0); |
331 | 26 | global_indices->insert(GlobalIndex(cast_set<size_t>(slot_ref->column_id()))); |
332 | 26 | } |
333 | 77 | for (const auto& child : expr->children()) { |
334 | 52 | collect_global_indices(child, global_indices); |
335 | 52 | } |
336 | 77 | } |
337 | | |
338 | | Status build_table_filters_from_conjunct(const VExprContextSPtr& conjunct, RuntimeState* state, |
339 | 25 | std::vector<TableFilter>* table_filters) { |
340 | 25 | if (conjunct == nullptr) { |
341 | 0 | return Status::OK(); |
342 | 0 | } |
343 | 25 | std::set<GlobalIndex> global_indices; |
344 | 25 | collect_global_indices(conjunct->root(), &global_indices); |
345 | 25 | if (!global_indices.empty()) { |
346 | 25 | TableFilter table_filter; |
347 | 25 | VExprSPtr filter_root; |
348 | 25 | RETURN_IF_ERROR(clone_table_expr_tree(conjunct->root(), &filter_root)); |
349 | 25 | table_filter.conjunct = VExprContext::create_shared(std::move(filter_root)); |
350 | 26 | for (const auto global_index : global_indices) { |
351 | 26 | table_filter.global_indices.push_back(global_index); |
352 | 26 | } |
353 | 25 | table_filters->push_back(std::move(table_filter)); |
354 | 25 | } |
355 | 25 | return Status::OK(); |
356 | 25 | } |
357 | | |
358 | | Status parse_deletion_vector(const char* buf, size_t buffer_size, DeleteFileDesc::Format format, |
359 | 5 | DeleteRows* delete_rows) { |
360 | 5 | DORIS_CHECK(buf != nullptr); |
361 | 5 | DORIS_CHECK(delete_rows != nullptr); |
362 | 5 | DORIS_CHECK(format == DeleteFileDesc::Format::PAIMON || |
363 | 5 | format == DeleteFileDesc::Format::ICEBERG); |
364 | | |
365 | 5 | if (format == DeleteFileDesc::Format::PAIMON) { |
366 | 1 | RETURN_IF_ERROR(decode_paimon_deletion_vector_buffer(buf, buffer_size, delete_rows)); |
367 | 1 | return Status::OK(); |
368 | 1 | } |
369 | | |
370 | 4 | roaring::Roaring64Map bitmap; |
371 | 4 | RETURN_IF_ERROR(decode_iceberg_deletion_vector_buffer(buf, buffer_size, &bitmap)); |
372 | 3 | delete_rows->reserve(bitmap.cardinality()); |
373 | 7 | for (auto it = bitmap.begin(); it != bitmap.end(); it++) { |
374 | 4 | delete_rows->push_back(cast_set<int64_t>(*it)); |
375 | 4 | } |
376 | 3 | return Status::OK(); |
377 | 4 | } |
378 | | |
379 | | } // namespace |
380 | | |
381 | | std::shared_ptr<io::FileSystemProperties> create_system_properties( |
382 | 93 | const TFileScanRangeParams* scan_params) { |
383 | 93 | auto system_properties = std::make_shared<io::FileSystemProperties>(); |
384 | 93 | if (scan_params == nullptr || !scan_params->__isset.file_type) { |
385 | 76 | system_properties->system_type = TFileType::FILE_LOCAL; |
386 | 76 | return system_properties; |
387 | 76 | } |
388 | 17 | system_properties->system_type = scan_params->file_type; |
389 | 17 | system_properties->properties = scan_params->properties; |
390 | 17 | system_properties->hdfs_params = scan_params->hdfs_params; |
391 | 17 | if (scan_params->__isset.broker_addresses) { |
392 | 0 | system_properties->broker_addresses.assign(scan_params->broker_addresses.begin(), |
393 | 0 | scan_params->broker_addresses.end()); |
394 | 0 | } |
395 | 17 | return system_properties; |
396 | 93 | } |
397 | | |
398 | 12 | std::string TableReader::debug_string() const { |
399 | 12 | std::ostringstream out; |
400 | 12 | out << "TableReader{format=" << file_format_to_string(_format) |
401 | 12 | << ", push_down_agg_type=" << push_down_agg_to_string(_push_down_agg_type) |
402 | 12 | << ", aggregate_pushdown_tried=" << _aggregate_pushdown_tried |
403 | 12 | << ", has_current_reader=" << (_data_reader.reader != nullptr) |
404 | 12 | << ", has_current_task=" << (_current_task != nullptr) |
405 | 12 | << ", current_file=" << current_file_debug_string(_current_task) |
406 | 12 | << ", has_delete_rows=" << (_delete_rows != nullptr) |
407 | 12 | << ", delete_row_count=" << (_delete_rows == nullptr ? 0 : _delete_rows->size()) |
408 | 12 | << ", has_system_properties=" << (_system_properties != nullptr) << ", system_type=" |
409 | 12 | << (_system_properties == nullptr ? static_cast<int>(TFileType::FILE_LOCAL) |
410 | 12 | : static_cast<int>(_system_properties->system_type)) |
411 | 12 | << ", has_scan_params=" << (_scan_params != nullptr) |
412 | 12 | << ", has_io_ctx=" << (_io_ctx != nullptr) |
413 | 12 | << ", has_runtime_state=" << (_runtime_state != nullptr) |
414 | 12 | << ", has_scanner_profile=" << (_scanner_profile != nullptr) |
415 | 12 | << ", mapper_options=" << _mapper_options.debug_string() << ", projected_columns=" |
416 | 12 | << join_table_reader_debug_strings( |
417 | 12 | _projected_columns, |
418 | 12 | [](const ColumnDefinition& column) { return column.debug_string(); }) |
419 | 12 | << ", partition_values=" << partition_values_debug_string(_partition_values) |
420 | 12 | << ", table_filters=" |
421 | 12 | << join_table_reader_debug_strings( |
422 | 12 | _table_filters, |
423 | 12 | [](const TableFilter& filter) { return table_filter_debug_string(filter); }) |
424 | 12 | << ", conjunct_count=" << _conjuncts.size() << ", conjuncts=" |
425 | 12 | << join_table_reader_debug_strings(_conjuncts, |
426 | 12 | [](const VExprContextSPtr& conjunct) { |
427 | 1 | return expr_context_debug_string(conjunct); |
428 | 1 | }) |
429 | 12 | << ", file_schema=" |
430 | 12 | << join_table_reader_debug_strings( |
431 | 12 | _data_reader.file_schema, |
432 | 12 | [](const ColumnDefinition& field) { return field.debug_string(); }) |
433 | 12 | << ", file_block_layout=" |
434 | 12 | << join_table_reader_debug_strings( |
435 | 12 | _data_reader.file_block_layout, |
436 | 12 | [](const FileBlockColumn& column) { |
437 | 2 | std::ostringstream column_out; |
438 | 2 | column_out << "FileBlockColumn{file_column_id=" << column.file_column_id |
439 | 2 | << ", name=" << column.name << ", type=" |
440 | 2 | << (column.type == nullptr ? "null" : column.type->get_name()) |
441 | 2 | << "}"; |
442 | 2 | return column_out.str(); |
443 | 2 | }) |
444 | 12 | << ", block_template_columns=" << _data_reader.block_template.columns() |
445 | 12 | << ", column_mapper=" |
446 | 12 | << (_data_reader.column_mapper == nullptr ? "null" |
447 | 12 | : _data_reader.column_mapper->debug_string()) |
448 | 12 | << "}"; |
449 | 12 | return out.str(); |
450 | 12 | } |
451 | | |
452 | | Status TableReader::annotate_projected_column(const TFileScanSlotInfo& slot_info, |
453 | | ProjectedColumnBuildContext* context, |
454 | 7 | ColumnDefinition* column) const { |
455 | 7 | (void)slot_info; |
456 | 7 | DORIS_CHECK(context != nullptr); |
457 | 7 | DORIS_CHECK(column != nullptr); |
458 | 7 | context->schema_column.reset(); |
459 | 7 | const auto* schema_field = find_external_root_field(context->scan_params, *column); |
460 | 7 | if (schema_field == nullptr) { |
461 | 6 | return Status::OK(); |
462 | 6 | } |
463 | 1 | context->schema_column = build_schema_column_from_external_field(*schema_field, column->type); |
464 | 1 | column->identifier = context->schema_column->identifier; |
465 | 1 | column->name_mapping = context->schema_column->name_mapping; |
466 | 1 | return Status::OK(); |
467 | 7 | } |
468 | | |
469 | 93 | Status TableReader::init(TableReadOptions&& options) { |
470 | 93 | _scan_params = options.scan_params; |
471 | 93 | _format = options.format; |
472 | 93 | _io_ctx = options.io_ctx; |
473 | 93 | _runtime_state = options.runtime_state; |
474 | 93 | _scanner_profile = options.scanner_profile; |
475 | 93 | _file_slot_descs = options.file_slot_descs; |
476 | 93 | _push_down_agg_type = options.push_down_agg_type; |
477 | 93 | _condition_cache_digest = options.condition_cache_digest; |
478 | 93 | _projected_columns = std::move(options.projected_columns); |
479 | 93 | _system_properties = create_system_properties(_scan_params); |
480 | 93 | _mapper_options.mode = TableColumnMappingMode::BY_NAME; |
481 | 93 | _conjuncts = std::move(options.conjuncts); |
482 | | |
483 | 93 | if (_scanner_profile != nullptr) { |
484 | 21 | static const char* table_profile = "TableReader"; |
485 | 21 | ADD_TIMER_WITH_LEVEL(_scanner_profile, table_profile, 1); |
486 | 21 | _profile.num_delete_files = ADD_CHILD_COUNTER_WITH_LEVEL(_scanner_profile, "NumDeleteFiles", |
487 | 21 | TUnit::UNIT, table_profile, 1); |
488 | 21 | _profile.num_delete_rows = ADD_CHILD_COUNTER_WITH_LEVEL(_scanner_profile, "NumDeleteRows", |
489 | 21 | TUnit::UNIT, table_profile, 1); |
490 | 21 | _profile.parse_delete_file_time = ADD_CHILD_TIMER_WITH_LEVEL( |
491 | 21 | _scanner_profile, "ParseDeleteFileTime", table_profile, 1); |
492 | 21 | _profile.exec_timer = |
493 | 21 | ADD_CHILD_TIMER_WITH_LEVEL(_scanner_profile, "GetBlockTime", table_profile, 1); |
494 | 21 | _profile.prepare_split_timer = |
495 | 21 | ADD_CHILD_TIMER_WITH_LEVEL(_scanner_profile, "PrepareSplitTime", table_profile, 1); |
496 | 21 | _profile.finalize_timer = |
497 | 21 | ADD_CHILD_TIMER_WITH_LEVEL(_scanner_profile, "FinalizeBlockTime", table_profile, 1); |
498 | 21 | _profile.create_reader_timer = |
499 | 21 | ADD_CHILD_TIMER_WITH_LEVEL(_scanner_profile, "CreateReaderTime", table_profile, 1); |
500 | 21 | _profile.pushdown_agg_timer = |
501 | 21 | ADD_CHILD_TIMER_WITH_LEVEL(_scanner_profile, "PushDownAggTime", table_profile, 1); |
502 | 21 | _profile.open_reader_timer = |
503 | 21 | ADD_CHILD_TIMER_WITH_LEVEL(_scanner_profile, "OpenReaderTime", table_profile, 1); |
504 | 21 | } |
505 | 93 | return Status::OK(); |
506 | 93 | } |
507 | | |
508 | 67 | Status TableReader::_build_table_filters_from_conjuncts() { |
509 | 67 | _table_filters.clear(); |
510 | 67 | for (const auto& conjunct : _conjuncts) { |
511 | 25 | RETURN_IF_ERROR( |
512 | 25 | build_table_filters_from_conjunct(conjunct, _runtime_state, &_table_filters)); |
513 | 25 | } |
514 | 67 | return Status::OK(); |
515 | 67 | } |
516 | | |
517 | 66 | Status TableReader::_open_local_filter_exprs(const FileScanRequest& file_request) { |
518 | 66 | RowDescriptor row_desc; |
519 | 66 | for (const auto& conjunct : file_request.conjuncts) { |
520 | 20 | RETURN_IF_ERROR(conjunct->prepare(_runtime_state, row_desc)); |
521 | 20 | RETURN_IF_ERROR(conjunct->open(_runtime_state)); |
522 | 20 | } |
523 | 66 | for (const auto& delete_conjunct : file_request.delete_conjuncts) { |
524 | 12 | RETURN_IF_ERROR(delete_conjunct->prepare(_runtime_state, row_desc)); |
525 | 12 | RETURN_IF_ERROR(delete_conjunct->open(_runtime_state)); |
526 | 12 | } |
527 | 66 | return Status::OK(); |
528 | 66 | } |
529 | | |
530 | 66 | bool TableReader::_should_enable_condition_cache(const FileScanRequest& file_request) const { |
531 | 66 | if (_condition_cache_digest == 0 || _push_down_agg_type == TPushAggOp::type::COUNT || |
532 | 66 | _current_file_description == std::nullopt || _data_reader.reader == nullptr) { |
533 | 61 | return false; |
534 | 61 | } |
535 | | // Condition cache is populated by file readers after evaluating file-local row-level |
536 | | // conjuncts. Metadata pruning can skip row groups/pages, but it does not produce a per-row |
537 | | // survivor bitmap that can safely populate the cache. |
538 | 5 | if (file_request.conjuncts.empty()) { |
539 | 1 | return false; |
540 | 1 | } |
541 | | // Delete files/deletion vectors are table-format state. They may change independently of the |
542 | | // data file path/mtime/size used by the external cache key, so caching their result can become |
543 | | // stale. Keep delete filtering enabled, but do not read or write condition cache. |
544 | 4 | if (_delete_rows != nullptr || !file_request.delete_conjuncts.empty()) { |
545 | 1 | return false; |
546 | 1 | } |
547 | | // Runtime filters can arrive late and their payload is not guaranteed to be represented by the |
548 | | // scan-local digest. Without a read-only mode, a MISS could insert a bitmap for P AND RF under |
549 | | // the digest for only P. This mirrors the old FileScanner guard. |
550 | 3 | return !contains_runtime_filter(file_request.conjuncts); |
551 | 4 | } |
552 | | |
553 | 66 | Status TableReader::_init_reader_condition_cache(const FileScanRequest& file_request) { |
554 | 66 | _condition_cache = nullptr; |
555 | 66 | _condition_cache_ctx = nullptr; |
556 | 66 | if (!_should_enable_condition_cache(file_request)) { |
557 | 64 | return Status::OK(); |
558 | 64 | } |
559 | | |
560 | 2 | auto* cache = segment_v2::ConditionCache::instance(); |
561 | 2 | if (cache == nullptr) { |
562 | 0 | return Status::OK(); |
563 | 0 | } |
564 | 2 | const auto& file = *_current_file_description; |
565 | 2 | _condition_cache_key = segment_v2::ConditionCache::ExternalCacheKey( |
566 | 2 | file.path, file.mtime, file.file_size, _condition_cache_digest, file.range_start_offset, |
567 | 2 | file.range_size); |
568 | | |
569 | 2 | segment_v2::ConditionCacheHandle handle; |
570 | 2 | const bool condition_cache_hit = cache->lookup(_condition_cache_key, &handle); |
571 | 2 | if (condition_cache_hit) { |
572 | 0 | _condition_cache = handle.get_filter_result(); |
573 | 0 | ++_condition_cache_hit_count; |
574 | 2 | } else { |
575 | 2 | const int64_t total_rows = _data_reader.reader->get_total_rows(); |
576 | 2 | if (total_rows <= 0) { |
577 | 0 | return Status::OK(); |
578 | 0 | } |
579 | | // Add one guard granule for split ranges that start in the middle of a granule. A guard |
580 | | // false bit beyond the real range never overlaps real rows, but avoids boundary overflow |
581 | | // when a reader marks the last partial granule. |
582 | 2 | const size_t num_granules = (total_rows + ConditionCacheContext::GRANULE_SIZE - 1) / |
583 | 2 | ConditionCacheContext::GRANULE_SIZE; |
584 | 2 | _condition_cache = std::make_shared<std::vector<bool>>(num_granules + 1, false); |
585 | 2 | } |
586 | | |
587 | 2 | if (_condition_cache != nullptr) { |
588 | 2 | _condition_cache_ctx = std::make_shared<ConditionCacheContext>(); |
589 | 2 | _condition_cache_ctx->is_hit = condition_cache_hit; |
590 | 2 | _condition_cache_ctx->filter_result = _condition_cache; |
591 | 2 | _data_reader.reader->set_condition_cache_context(_condition_cache_ctx); |
592 | 2 | } |
593 | 2 | return Status::OK(); |
594 | 2 | } |
595 | | |
596 | 66 | void TableReader::_finalize_reader_condition_cache() { |
597 | 66 | if (_condition_cache_ctx == nullptr || _condition_cache_ctx->is_hit) { |
598 | 64 | _condition_cache = nullptr; |
599 | 64 | _condition_cache_ctx = nullptr; |
600 | 64 | return; |
601 | 64 | } |
602 | | // LIMIT or scanner cancellation may close a reader before all selected row ranges are visited. |
603 | | // Unvisited granules remain false in a MISS bitmap, so inserting a partial bitmap would make a |
604 | | // later HIT skip valid rows. Only publish cache entries after the physical reader reaches EOF. |
605 | 2 | if (!_current_reader_reached_eof) { |
606 | 1 | _condition_cache = nullptr; |
607 | 1 | _condition_cache_ctx = nullptr; |
608 | 1 | return; |
609 | 1 | } |
610 | 1 | segment_v2::ConditionCache::instance()->insert(_condition_cache_key, |
611 | 1 | std::move(_condition_cache)); |
612 | 1 | _condition_cache = nullptr; |
613 | 1 | _condition_cache_ctx = nullptr; |
614 | 1 | } |
615 | | |
616 | 78 | Status TableReader::create_next_reader(bool* eos) { |
617 | 78 | SCOPED_TIMER(_profile.create_reader_timer); |
618 | 78 | DCHECK(_data_reader.reader == nullptr); |
619 | 78 | if (_current_task == nullptr) { |
620 | 11 | *eos = true; |
621 | 11 | return Status::OK(); |
622 | 11 | } |
623 | | |
624 | 67 | RETURN_IF_ERROR(create_file_reader(&_data_reader.reader)); |
625 | 67 | DORIS_CHECK(_data_reader.reader != nullptr); |
626 | 67 | if (_batch_size > 0) { |
627 | 0 | _data_reader.reader->set_batch_size(_batch_size); |
628 | 0 | } |
629 | 67 | Status st = _data_reader.reader->init(_runtime_state); |
630 | 67 | if (!st.ok()) { |
631 | 0 | if (_io_ctx != nullptr && _io_ctx->should_stop && st.is<ErrorCode::END_OF_FILE>()) { |
632 | 0 | *eos = true; |
633 | 0 | _data_reader.reader.reset(); |
634 | 0 | return Status::OK(); |
635 | 0 | } |
636 | 0 | return st; |
637 | 0 | } |
638 | 67 | st = open_reader(); |
639 | 67 | if (!st.ok()) { |
640 | 0 | if (_io_ctx != nullptr && _io_ctx->should_stop && st.is<ErrorCode::END_OF_FILE>()) { |
641 | 0 | *eos = true; |
642 | 0 | _data_reader.reader.reset(); |
643 | 0 | return Status::OK(); |
644 | 0 | } |
645 | 0 | return st; |
646 | 0 | } |
647 | 67 | if (_data_reader.reader == nullptr) { |
648 | 1 | *eos = _current_task == nullptr; |
649 | 1 | return Status::OK(); |
650 | 1 | } |
651 | 66 | *eos = false; |
652 | 66 | return Status::OK(); |
653 | 67 | } |
654 | | |
655 | 57 | Status TableReader::create_file_reader(std::unique_ptr<FileReader>* reader) { |
656 | 57 | DORIS_CHECK(reader != nullptr); |
657 | 57 | if (_format == FileFormat::PARQUET) { |
658 | 57 | const bool enable_mapping_timestamp_tz = |
659 | 57 | _scan_params != nullptr && _scan_params->__isset.enable_mapping_timestamp_tz && |
660 | 57 | _scan_params->enable_mapping_timestamp_tz; |
661 | 57 | *reader = std::make_unique<format::parquet::ParquetReader>( |
662 | 57 | _system_properties, _current_task->data_file, _io_ctx, _scanner_profile, |
663 | 57 | _global_rowid_context, enable_mapping_timestamp_tz); |
664 | 57 | return Status::OK(); |
665 | 57 | } |
666 | 0 | if (_format == FileFormat::CSV) { |
667 | 0 | if (_file_slot_descs == nullptr) { |
668 | 0 | return Status::InvalidArgument("CSV reader requires file slot descriptors"); |
669 | 0 | } |
670 | | // CSV has no embedded schema. TableReader owns table-level mapping, while CsvReader needs |
671 | | // only the physical file slots plus scan text parameters to build a file-local schema. |
672 | | // Non-file columns such as partitions/defaults/virtual row ids are intentionally excluded |
673 | | // from `_file_slot_descs` and are materialized during finalize_chunk(). |
674 | 0 | *reader = std::make_unique<format::csv::CsvReader>( |
675 | 0 | _system_properties, _current_task->data_file, _io_ctx, _scanner_profile, |
676 | 0 | _scan_params, *_file_slot_descs, _current_range_compress_type, |
677 | 0 | _current_range_load_id); |
678 | 0 | return Status::OK(); |
679 | 0 | } |
680 | 0 | if (_format == FileFormat::TEXT) { |
681 | 0 | if (_file_slot_descs == nullptr) { |
682 | 0 | return Status::InvalidArgument("Text reader requires file slot descriptors"); |
683 | 0 | } |
684 | | // Text files have no embedded schema. As with CSV, TableReader handles table-level mapping |
685 | | // and only passes physical file slots to the v2 TextReader. |
686 | 0 | *reader = std::make_unique<format::text::TextReader>( |
687 | 0 | _system_properties, _current_task->data_file, _io_ctx, _scanner_profile, |
688 | 0 | _scan_params, *_file_slot_descs, _current_range_compress_type, |
689 | 0 | _current_range_load_id); |
690 | 0 | return Status::OK(); |
691 | 0 | } |
692 | 0 | if (_format == FileFormat::JSON) { |
693 | 0 | if (_file_slot_descs == nullptr) { |
694 | 0 | return Status::InvalidArgument("JSON reader requires file slot descriptors"); |
695 | 0 | } |
696 | 0 | *reader = std::make_unique<format::json::JsonReader>( |
697 | 0 | _system_properties, _current_task->data_file, _io_ctx, _scanner_profile, |
698 | 0 | _scan_params, _current_file_range_desc, *_file_slot_descs, |
699 | 0 | _current_range_compress_type, _current_range_load_id); |
700 | 0 | return Status::OK(); |
701 | 0 | } |
702 | 0 | if (_format == FileFormat::NATIVE) { |
703 | 0 | *reader = std::make_unique<format::native::NativeReader>( |
704 | 0 | _system_properties, _current_task->data_file, _io_ctx, _scanner_profile); |
705 | 0 | return Status::OK(); |
706 | 0 | } |
707 | 0 | return Status::NotSupported("TableReader does not support file format {}", |
708 | 0 | file_format_to_string(_format)); |
709 | 0 | } |
710 | | |
711 | 83 | std::unique_ptr<io::FileDescription> create_file_description(const TFileRangeDesc& range) { |
712 | 83 | auto file_description = std::make_unique<io::FileDescription>(); |
713 | 83 | file_description->path = range.path; |
714 | 83 | file_description->file_size = range.__isset.file_size ? range.file_size : -1; |
715 | 83 | file_description->mtime = range.__isset.modification_time ? range.modification_time : 0; |
716 | 83 | file_description->range_start_offset = range.__isset.start_offset ? range.start_offset : 0; |
717 | 83 | file_description->range_size = range.__isset.size ? range.size : -1; |
718 | 83 | if (range.__isset.fs_name) { |
719 | 1 | file_description->fs_name = range.fs_name; |
720 | 1 | } |
721 | 83 | if (range.__isset.file_cache_admission) { |
722 | 0 | file_description->file_cache_admission = range.file_cache_admission; |
723 | 0 | } |
724 | 83 | return file_description; |
725 | 83 | } |
726 | | |
727 | 83 | Status TableReader::prepare_split(const SplitReadOptions& options) { |
728 | 83 | SCOPED_TIMER(_profile.prepare_split_timer); |
729 | | // Update to current split format to handle ORC/PARQUET files in one table. |
730 | 83 | _format = options.current_split_format; |
731 | 83 | _partition_values = std::move(options.partition_values); |
732 | 83 | _current_task = std::make_unique<ScanTask>(); |
733 | 83 | _current_task->data_file = create_file_description(options.current_range); |
734 | 83 | _current_file_description = *_current_task->data_file; |
735 | 83 | _current_file_range_desc = options.current_range; |
736 | 83 | _current_range_compress_type = options.current_range.__isset.compress_type |
737 | 83 | ? options.current_range.compress_type |
738 | 83 | : TFileCompressType::UNKNOWN; |
739 | 83 | _current_range_load_id = options.current_range.__isset.load_id |
740 | 83 | ? std::make_optional(options.current_range.load_id) |
741 | 83 | : std::nullopt; |
742 | 83 | _global_rowid_context = options.global_rowid_context; |
743 | 83 | _delete_rows = nullptr; |
744 | 83 | _aggregate_pushdown_tried = false; |
745 | 83 | _remaining_table_level_count = -1; |
746 | 83 | _current_reader_reached_eof = false; |
747 | 83 | if (_push_down_agg_type == TPushAggOp::type::COUNT && |
748 | 83 | options.current_range.__isset.table_format_params && |
749 | 83 | options.current_range.table_format_params.__isset.table_level_row_count) { |
750 | 6 | DORIS_CHECK(options.current_range.table_format_params.table_level_row_count >= -1); |
751 | 6 | _remaining_table_level_count = |
752 | 6 | options.current_range.table_format_params.table_level_row_count; |
753 | 6 | } |
754 | 83 | if (_is_table_level_count_active()) { |
755 | 2 | return Status::OK(); |
756 | 2 | } |
757 | 81 | return _parse_delete_predicates(options); |
758 | 83 | } |
759 | | |
760 | 81 | Status TableReader::_parse_delete_predicates(const SplitReadOptions& options) { |
761 | 81 | DeleteFileDesc desc {.fs_name = options.current_range.fs_name}; |
762 | 81 | bool has_delete_file = false; |
763 | 81 | RETURN_IF_ERROR(_parse_deletion_vector_file(options.current_range.table_format_params, &desc, |
764 | 81 | &has_delete_file)); |
765 | 81 | if (has_delete_file) { |
766 | 7 | DORIS_CHECK(options.cache != nullptr); |
767 | 7 | Status create_status = Status::OK(); |
768 | | |
769 | 7 | _delete_rows = options.cache->get<DeleteRows>(desc.key, [&]() -> DeleteRows* { |
770 | 7 | auto delete_rows = std::make_unique<DeleteRows>(); |
771 | | |
772 | 7 | DeletionVectorReader dv_reader(_runtime_state, _scanner_profile, *_scan_params, desc, |
773 | 7 | _io_ctx.get()); |
774 | 7 | create_status = dv_reader.open(); |
775 | 7 | if (!create_status.ok()) [[unlikely]] { |
776 | 0 | return nullptr; |
777 | 0 | } |
778 | | |
779 | 7 | size_t bytes_read = desc.size; |
780 | 7 | std::vector<char> buffer(bytes_read); |
781 | 7 | DBUG_EXECUTE_IF("TableReader.parse_deletion_vector.io_error", { |
782 | 7 | create_status = Status::IOError("injected format v2 deletion vector read failure"); |
783 | 7 | return nullptr; |
784 | 7 | }); |
785 | 6 | DBUG_EXECUTE_IF("TableReader.parse_deletion_vector.should_stop", { |
786 | 6 | create_status = Status::EndOfFile("stop read."); |
787 | 6 | return nullptr; |
788 | 6 | }); |
789 | 5 | create_status = dv_reader.read_at(desc.start_offset, {buffer.data(), bytes_read}); |
790 | 5 | if (!create_status.ok()) [[unlikely]] { |
791 | 0 | return nullptr; |
792 | 0 | } |
793 | | |
794 | 5 | const char* buf = buffer.data(); |
795 | 5 | SCOPED_TIMER(_profile.parse_delete_file_time); |
796 | 5 | create_status = parse_deletion_vector(buf, bytes_read, desc.format, delete_rows.get()); |
797 | 5 | if (!create_status.ok()) [[unlikely]] { |
798 | 1 | return nullptr; |
799 | 1 | } |
800 | 4 | COUNTER_UPDATE(_profile.num_delete_rows, delete_rows->size()); |
801 | 4 | return delete_rows.release(); |
802 | 5 | }); |
803 | 7 | RETURN_IF_ERROR(create_status); |
804 | 7 | } |
805 | | |
806 | 78 | return Status::OK(); |
807 | 81 | } |
808 | | } // namespace doris::format |