be/src/exec/connector/jni_connector.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 <jni.h> |
21 | | #include <string.h> |
22 | | |
23 | | #include <map> |
24 | | #include <memory> |
25 | | #include <string> |
26 | | #include <unordered_map> |
27 | | #include <utility> |
28 | | #include <vector> |
29 | | |
30 | | #include "common/status.h" |
31 | | #include "core/data_type/data_type.h" |
32 | | #include "core/data_type/define_primitive_type.h" |
33 | | #include "core/data_type/primitive_type.h" |
34 | | #include "core/string_ref.h" |
35 | | #include "exprs/aggregate/aggregate_function.h" |
36 | | #include "runtime/runtime_profile.h" |
37 | | #include "storage/olap_scan_common.h" |
38 | | #include "storage/olap_utils.h" |
39 | | #include "util/jni-util.h" |
40 | | #include "util/profile_collector.h" |
41 | | #include "util/string_util.h" |
42 | | |
43 | | namespace doris { |
44 | | #include "common/compile_check_begin.h" |
45 | | class RuntimeState; |
46 | | |
47 | | class Block; |
48 | | template <PrimitiveType T> |
49 | | class ColumnDecimal; |
50 | | template <PrimitiveType T> |
51 | | class ColumnVector; |
52 | | } // namespace doris |
53 | | |
54 | | namespace doris { |
55 | | |
56 | | /** |
57 | | * Connector to java jni scanner, which should extend org.apache.doris.common.jni.JniScanner |
58 | | */ |
59 | | class JniConnector : public ProfileCollector { |
60 | | public: |
61 | | class TableMetaAddress { |
62 | | private: |
63 | | long* _meta_ptr; |
64 | | int _meta_index; |
65 | | |
66 | | public: |
67 | 0 | TableMetaAddress() { |
68 | 0 | _meta_ptr = nullptr; |
69 | 0 | _meta_index = 0; |
70 | 0 | } |
71 | | |
72 | 0 | TableMetaAddress(long meta_addr) { |
73 | 0 | _meta_ptr = static_cast<long*>(reinterpret_cast<void*>(meta_addr)); |
74 | 0 | _meta_index = 0; |
75 | 0 | } |
76 | | |
77 | 0 | void set_meta(long meta_addr) { |
78 | 0 | _meta_ptr = static_cast<long*>(reinterpret_cast<void*>(meta_addr)); |
79 | 0 | _meta_index = 0; |
80 | 0 | } |
81 | | |
82 | 0 | long next_meta_as_long() { return _meta_ptr[_meta_index++]; } |
83 | | |
84 | 0 | void* next_meta_as_ptr() { return reinterpret_cast<void*>(_meta_ptr[_meta_index++]); } |
85 | | }; |
86 | | |
87 | | /** |
88 | | * The predicates that can be pushed down to java side. |
89 | | * Reference to java class org.apache.doris.common.jni.vec.ScanPredicate |
90 | | */ |
91 | | template <typename CppType> |
92 | | struct ScanPredicate { |
93 | | ScanPredicate() = default; |
94 | | ~ScanPredicate() = default; |
95 | | std::string column_name; |
96 | | SQLFilterOp op; |
97 | | std::vector<const CppType*> values; |
98 | | int scale; |
99 | | |
100 | | ScanPredicate(const std::string column_name) : column_name(std::move(column_name)) {} |
101 | | |
102 | | ScanPredicate(const ScanPredicate& other) |
103 | | : column_name(other.column_name), op(other.op), scale(other.scale) { |
104 | | for (auto v : other.values) { |
105 | | values.emplace_back(v); |
106 | | } |
107 | | } |
108 | | |
109 | | int length() { |
110 | | // name_length(4) + column_name + operator(4) + scale(4) + num_values(4) |
111 | | int len = 4 + static_cast<int>(column_name.size()) + 4 + 4 + 4; |
112 | | if constexpr (std::is_same_v<CppType, StringRef>) { |
113 | | for (const StringRef* s : values) { |
114 | | // string_length(4) + string |
115 | | len += static_cast<int>(4 + s->size); |
116 | | } |
117 | | } else { |
118 | | int type_len = sizeof(CppType); |
119 | | // value_length(4) + value |
120 | | len += static_cast<int>((4 + type_len) * values.size()); |
121 | | } |
122 | | return len; |
123 | | } |
124 | | |
125 | | /** |
126 | | * The value ranges can be stored as byte array as following format: |
127 | | * number_filters(4) | length(4) | column_name | op(4) | scale(4) | num_values(4) | value_length(4) | value | ... |
128 | | * The read method is implemented in org.apache.doris.common.jni.vec.ScanPredicate#parseScanPredicates |
129 | | */ |
130 | | int write(std::unique_ptr<char[]>& predicates, int origin_length) { |
131 | | int num_filters = 0; |
132 | | if (origin_length != 0) { |
133 | | num_filters = *reinterpret_cast<int*>(predicates.get()); |
134 | | } else { |
135 | | origin_length = 4; |
136 | | } |
137 | | num_filters += 1; |
138 | | int new_length = origin_length + length(); |
139 | | char* new_bytes = new char[new_length]; |
140 | | if (origin_length != 4) { |
141 | | memcpy(new_bytes, predicates.get(), origin_length); |
142 | | } |
143 | | *reinterpret_cast<int*>(new_bytes) = num_filters; |
144 | | |
145 | | char* char_ptr = new_bytes + origin_length; |
146 | | *reinterpret_cast<int*>(char_ptr) = static_cast<int>(column_name.size()); |
147 | | char_ptr += 4; |
148 | | memcpy(char_ptr, column_name.data(), column_name.size()); |
149 | | char_ptr += static_cast<int>(column_name.size()); |
150 | | *reinterpret_cast<int*>(char_ptr) = op; |
151 | | char_ptr += 4; |
152 | | *reinterpret_cast<int*>(char_ptr) = scale; |
153 | | char_ptr += 4; |
154 | | *reinterpret_cast<int*>(char_ptr) = static_cast<int>(values.size()); |
155 | | char_ptr += 4; |
156 | | if constexpr (std::is_same_v<CppType, StringRef>) { |
157 | | for (const StringRef* s : values) { |
158 | | *reinterpret_cast<int*>(char_ptr) = static_cast<int>(s->size); |
159 | | char_ptr += 4; |
160 | | memcpy(char_ptr, s->data, s->size); |
161 | | char_ptr += static_cast<int>(s->size); |
162 | | } |
163 | | } else { |
164 | | // FIXME: it can not handle decimal type correctly. |
165 | | // but this logic is deprecated and not used. |
166 | | // so may be deleted or fixed later. |
167 | | for (const CppType* v : values) { |
168 | | int type_len = sizeof(CppType); |
169 | | *reinterpret_cast<int*>(char_ptr) = type_len; |
170 | | char_ptr += 4; |
171 | | *reinterpret_cast<CppType*>(char_ptr) = *v; |
172 | | char_ptr += type_len; |
173 | | } |
174 | | } |
175 | | |
176 | | predicates.reset(new_bytes); |
177 | | return new_length; |
178 | | } |
179 | | }; |
180 | | |
181 | | /** |
182 | | * Use configuration map to provide scan information. The java side should determine how the parameters |
183 | | * are parsed. For example, using "required_fields=col0,col1,...,colN" to provide the scan fields. |
184 | | * @param connector_class Java scanner class |
185 | | * @param scanner_params Provided configuration map |
186 | | * @param column_names Fields to read, also the required_fields in scanner_params |
187 | | */ |
188 | | JniConnector(std::string connector_class, std::map<std::string, std::string> scanner_params, |
189 | | std::vector<std::string> column_names, int64_t self_split_weight = -1) |
190 | 0 | : _connector_class(std::move(connector_class)), |
191 | 0 | _scanner_params(std::move(scanner_params)), |
192 | 0 | _column_names(std::move(column_names)), |
193 | 0 | _self_split_weight(static_cast<int32_t>(self_split_weight)) { |
194 | | // Use java class name as connector name |
195 | 0 | _connector_name = split(_connector_class, "/").back(); |
196 | 0 | } |
197 | | |
198 | | /** |
199 | | * Just use to get the table schema. |
200 | | * @param connector_class Java scanner class |
201 | | * @param scanner_params Provided configuration map |
202 | | */ |
203 | | JniConnector(std::string connector_class, std::map<std::string, std::string> scanner_params) |
204 | 0 | : _connector_class(std::move(connector_class)), |
205 | 0 | _scanner_params(std::move(scanner_params)) { |
206 | 0 | _is_table_schema = true; |
207 | 0 | } |
208 | | |
209 | 0 | ~JniConnector() override = default; |
210 | | |
211 | | /** |
212 | | * Open java scanner, and get the following scanner methods by jni: |
213 | | * 1. getNextBatchMeta: read next batch and return the address of meta information |
214 | | * 2. close: close java scanner, and release jni resources |
215 | | * 3. releaseColumn: release a single column |
216 | | * 4. releaseTable: release current batch, which will also release columns and meta information |
217 | | */ |
218 | | Status open(RuntimeState* state, RuntimeProfile* profile); |
219 | | |
220 | | /** |
221 | | * Should call before open, parse the pushed down filters. The value ranges can be stored as byte array in heap: |
222 | | * number_filters(4) | length(4) | column_name | op(4) | scale(4) | num_values(4) | value_length(4) | value | ... |
223 | | * Then, pass the byte array address in configuration map, like "push_down_predicates=${address}" |
224 | | */ |
225 | | Status init(); |
226 | | |
227 | | /** |
228 | | * Call java side function JniScanner.getNextBatchMeta. The columns information are stored as long array: |
229 | | * | number of rows | |
230 | | * | null indicator start address of fixed length column-A | |
231 | | * | data column start address of the fixed length column-A | |
232 | | * | ... | |
233 | | * | null indicator start address of variable length column-B | |
234 | | * | offset column start address of the variable length column-B | |
235 | | * | data column start address of the variable length column-B | |
236 | | * | ... | |
237 | | */ |
238 | | Status get_next_block(Block* block, size_t* read_rows, bool* eof); |
239 | | |
240 | | /** |
241 | | * Get performance metrics from java scanner |
242 | | */ |
243 | | Status get_statistics(JNIEnv* env, std::map<std::string, std::string>* result); |
244 | | |
245 | | /** |
246 | | * Call java side function JniScanner.getTableSchema. |
247 | | * |
248 | | * The schema information are stored as json format |
249 | | */ |
250 | | Status get_table_schema(std::string& table_schema_str); |
251 | | |
252 | | /** |
253 | | * Close scanner and release jni resources. |
254 | | */ |
255 | | Status close(); |
256 | | |
257 | | /** |
258 | | * Set column name to block index map from FileScanner to avoid repeated map creation. |
259 | | */ |
260 | | void set_col_name_to_block_idx( |
261 | 0 | const std::unordered_map<std::string, uint32_t>* col_name_to_block_idx) { |
262 | 0 | _col_name_to_block_idx = col_name_to_block_idx; |
263 | 0 | } |
264 | | |
265 | | static std::string get_jni_type(const DataTypePtr& data_type); |
266 | | static std::string get_jni_type_with_different_string(const DataTypePtr& data_type); |
267 | | |
268 | | static Status to_java_table(Block* block, size_t num_rows, const ColumnNumbers& arguments, |
269 | | std::unique_ptr<long[]>& meta); |
270 | | |
271 | | static Status to_java_table(Block* block, std::unique_ptr<long[]>& meta); |
272 | | |
273 | | static std::pair<std::string, std::string> parse_table_schema(Block* block, |
274 | | const ColumnNumbers& arguments, |
275 | | bool ignore_column_name = true); |
276 | | |
277 | | static std::pair<std::string, std::string> parse_table_schema(Block* block); |
278 | | |
279 | | static Status fill_block(Block* block, const ColumnNumbers& arguments, long table_address); |
280 | | |
281 | | protected: |
282 | | void _collect_profile_before_close() override; |
283 | | |
284 | | private: |
285 | | std::string _connector_name; |
286 | | std::string _connector_class; |
287 | | std::map<std::string, std::string> _scanner_params; |
288 | | std::vector<std::string> _column_names; |
289 | | int32_t _self_split_weight; |
290 | | bool _is_table_schema = false; |
291 | | |
292 | | RuntimeState* _state = nullptr; |
293 | | RuntimeProfile* _profile = nullptr; |
294 | | RuntimeProfile::Counter* _open_scanner_time = nullptr; |
295 | | RuntimeProfile::Counter* _java_scan_time = nullptr; |
296 | | RuntimeProfile::Counter* _java_append_data_time = nullptr; |
297 | | RuntimeProfile::Counter* _java_create_vector_table_time = nullptr; |
298 | | RuntimeProfile::Counter* _fill_block_time = nullptr; |
299 | | std::map<std::string, RuntimeProfile::Counter*> _scanner_profile; |
300 | | RuntimeProfile::ConditionCounter* _max_time_split_weight_counter = nullptr; |
301 | | |
302 | | int64_t _jni_scanner_open_watcher = 0; |
303 | | int64_t _java_scan_watcher = 0; |
304 | | int64_t _fill_block_watcher = 0; |
305 | | |
306 | | size_t _has_read = 0; |
307 | | |
308 | | bool _closed = false; |
309 | | bool _scanner_opened = false; |
310 | | |
311 | | Jni::GlobalClass _jni_scanner_cls; |
312 | | Jni::GlobalObject _jni_scanner_obj; |
313 | | Jni::MethodId _jni_scanner_open; |
314 | | Jni::MethodId _jni_scanner_get_append_data_time; |
315 | | Jni::MethodId _jni_scanner_get_create_vector_table_time; |
316 | | Jni::MethodId _jni_scanner_get_next_batch; |
317 | | Jni::MethodId _jni_scanner_get_table_schema; |
318 | | Jni::MethodId _jni_scanner_close; |
319 | | Jni::MethodId _jni_scanner_release_column; |
320 | | Jni::MethodId _jni_scanner_release_table; |
321 | | Jni::MethodId _jni_scanner_get_statistics; |
322 | | |
323 | | TableMetaAddress _table_meta; |
324 | | |
325 | | int _predicates_length = 0; |
326 | | std::unique_ptr<char[]> _predicates; |
327 | | |
328 | | // Column name to block index map, passed from FileScanner to avoid repeated map creation |
329 | | const std::unordered_map<std::string, uint32_t>* _col_name_to_block_idx = nullptr; |
330 | | |
331 | | /** |
332 | | * Set the address of meta information, which is returned by org.apache.doris.common.jni.JniScanner#getNextBatchMeta |
333 | | */ |
334 | 0 | void _set_meta(long meta_addr) { _table_meta.set_meta(meta_addr); } |
335 | | |
336 | | Status _init_jni_scanner(JNIEnv* env, int batch_size); |
337 | | |
338 | | Status _fill_block(Block* block, size_t num_rows); |
339 | | |
340 | | static Status _fill_column(TableMetaAddress& address, ColumnPtr& doris_column, |
341 | | const DataTypePtr& data_type, size_t num_rows); |
342 | | |
343 | | static Status _fill_string_column(TableMetaAddress& address, MutableColumnPtr& doris_column, |
344 | | size_t num_rows); |
345 | | |
346 | | static Status _fill_varbinary_column(TableMetaAddress& address, MutableColumnPtr& doris_column, |
347 | | size_t num_rows); |
348 | | |
349 | | static Status _fill_map_column(TableMetaAddress& address, MutableColumnPtr& doris_column, |
350 | | const DataTypePtr& data_type, size_t num_rows); |
351 | | |
352 | | static Status _fill_array_column(TableMetaAddress& address, MutableColumnPtr& doris_column, |
353 | | const DataTypePtr& data_type, size_t num_rows); |
354 | | |
355 | | static Status _fill_struct_column(TableMetaAddress& address, MutableColumnPtr& doris_column, |
356 | | const DataTypePtr& data_type, size_t num_rows); |
357 | | |
358 | | static Status _fill_column_meta(const ColumnPtr& doris_column, const DataTypePtr& data_type, |
359 | | std::vector<long>& meta_data); |
360 | | |
361 | | template <typename COLUMN_TYPE, typename CPP_TYPE> |
362 | | requires(!std::is_same_v<COLUMN_TYPE, ColumnDecimal128V2> && |
363 | | !std::is_same_v<COLUMN_TYPE, ColumnDate> && |
364 | | !std::is_same_v<COLUMN_TYPE, ColumnDateTime> && |
365 | | !std::is_same_v<COLUMN_TYPE, ColumnDateV2> && |
366 | | !std::is_same_v<COLUMN_TYPE, ColumnDateTimeV2> && |
367 | | !std::is_same_v<COLUMN_TYPE, ColumnTimeStampTz>) |
368 | | static Status _fill_fixed_length_column(MutableColumnPtr& doris_column, CPP_TYPE* ptr, |
369 | 0 | size_t num_rows) { |
370 | 0 | auto& column_data = assert_cast<COLUMN_TYPE&>(*doris_column).get_data(); |
371 | 0 | size_t origin_size = column_data.size(); |
372 | 0 | column_data.resize(origin_size + num_rows); |
373 | 0 | memcpy(column_data.data() + origin_size, ptr, sizeof(CPP_TYPE) * num_rows); |
374 | 0 | return Status::OK(); |
375 | 0 | } Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE3EEEaQaaaaaaaaaantsr3stdE9is_same_vIT_NS_13ColumnDecimalILS3_20EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_11EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE2EEEhQaaaaaaaaaantsr3stdE9is_same_vIT_NS_13ColumnDecimalILS3_20EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_11EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE4EEEsQaaaaaaaaaantsr3stdE9is_same_vIT_NS_13ColumnDecimalILS3_20EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_11EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE5EEEiQaaaaaaaaaantsr3stdE9is_same_vIT_NS_13ColumnDecimalILS3_20EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_11EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE6EEElQaaaaaaaaaantsr3stdE9is_same_vIT_NS_13ColumnDecimalILS3_20EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_11EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE7EEEnQaaaaaaaaaantsr3stdE9is_same_vIT_NS_13ColumnDecimalILS3_20EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_11EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE8EEEfQaaaaaaaaaantsr3stdE9is_same_vIT_NS_13ColumnDecimalILS3_20EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_11EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE9EEEdQaaaaaaaaaantsr3stdE9is_same_vIT_NS_13ColumnDecimalILS3_20EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_11EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_13ColumnDecimalILNS_13PrimitiveTypeE30EEEnQaaaaaaaaaantsr3stdE9is_same_vIT_NS2_ILS3_20EEEEntsr3stdE9is_same_vIS5_NS_12ColumnVectorILS3_11EEEEntsr3stdE9is_same_vIS5_NS7_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS7_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS7_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS7_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_13ColumnDecimalILNS_13PrimitiveTypeE28EEEiQaaaaaaaaaantsr3stdE9is_same_vIT_NS2_ILS3_20EEEEntsr3stdE9is_same_vIS5_NS_12ColumnVectorILS3_11EEEEntsr3stdE9is_same_vIS5_NS7_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS7_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS7_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS7_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_13ColumnDecimalILNS_13PrimitiveTypeE29EEElQaaaaaaaaaantsr3stdE9is_same_vIT_NS2_ILS3_20EEEEntsr3stdE9is_same_vIS5_NS_12ColumnVectorILS3_11EEEEntsr3stdE9is_same_vIS5_NS7_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS7_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS7_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS7_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE36EEEjQaaaaaaaaaantsr3stdE9is_same_vIT_NS_13ColumnDecimalILS3_20EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_11EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE37EEEoQaaaaaaaaaantsr3stdE9is_same_vIT_NS_13ColumnDecimalILS3_20EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_11EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_12EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_25EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_26EEEEntsr3stdE9is_same_vIS5_NS2_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrISF_EEPT0_m |
376 | | |
377 | | template <typename COLUMN_TYPE, typename CPP_TYPE> |
378 | | requires(std::is_same_v<COLUMN_TYPE, ColumnDate> || |
379 | | std::is_same_v<COLUMN_TYPE, ColumnDateTime>) |
380 | | static Status _fill_fixed_length_column(MutableColumnPtr& doris_column, CPP_TYPE* ptr, |
381 | 0 | size_t num_rows) { |
382 | 0 | auto& column_data = assert_cast<COLUMN_TYPE&>(*doris_column).get_data(); |
383 | 0 | size_t origin_size = column_data.size(); |
384 | 0 | column_data.resize(origin_size + num_rows); |
385 | 0 | memcpy((int64_t*)column_data.data() + origin_size, ptr, sizeof(CPP_TYPE) * num_rows); |
386 | 0 | return Status::OK(); |
387 | 0 | } Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE11EEElQoosr3stdE9is_same_vIT_S4_Esr3stdE9is_same_vIS5_NS2_ILS3_12EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrIS9_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE12EEElQoosr3stdE9is_same_vIT_NS2_ILS3_11EEEEsr3stdE9is_same_vIS5_S4_EEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrIS9_EEPT0_m |
388 | | |
389 | | template <typename COLUMN_TYPE, typename CPP_TYPE> |
390 | | requires(std::is_same_v<COLUMN_TYPE, ColumnDateV2>) |
391 | | static Status _fill_fixed_length_column(MutableColumnPtr& doris_column, CPP_TYPE* ptr, |
392 | 0 | size_t num_rows) { |
393 | 0 | auto& column_data = assert_cast<COLUMN_TYPE&>(*doris_column).get_data(); |
394 | 0 | size_t origin_size = column_data.size(); |
395 | 0 | column_data.resize(origin_size + num_rows); |
396 | 0 | memcpy((uint32_t*)column_data.data() + origin_size, ptr, sizeof(CPP_TYPE) * num_rows); |
397 | 0 | return Status::OK(); |
398 | 0 | } |
399 | | |
400 | | template <typename COLUMN_TYPE, typename CPP_TYPE> |
401 | | requires(std::is_same_v<COLUMN_TYPE, ColumnDateTimeV2> || |
402 | | std::is_same_v<COLUMN_TYPE, ColumnTimeStampTz>) |
403 | | static Status _fill_fixed_length_column(MutableColumnPtr& doris_column, CPP_TYPE* ptr, |
404 | 0 | size_t num_rows) { |
405 | 0 | auto& column_data = assert_cast<COLUMN_TYPE&>(*doris_column).get_data(); |
406 | 0 | size_t origin_size = column_data.size(); |
407 | 0 | column_data.resize(origin_size + num_rows); |
408 | 0 | memcpy((uint64_t*)column_data.data() + origin_size, ptr, sizeof(CPP_TYPE) * num_rows); |
409 | 0 | return Status::OK(); |
410 | 0 | } Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE26EEEmQoosr3stdE9is_same_vIT_S4_Esr3stdE9is_same_vIS5_NS2_ILS3_42EEEEEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrIS9_EEPT0_m Unexecuted instantiation: _ZN5doris12JniConnector25_fill_fixed_length_columnINS_12ColumnVectorILNS_13PrimitiveTypeE42EEEmQoosr3stdE9is_same_vIT_NS2_ILS3_26EEEEsr3stdE9is_same_vIS5_S4_EEENS_6StatusERNS_3COWINS_7IColumnEE11mutable_ptrIS9_EEPT0_m |
411 | | |
412 | | template <typename COLUMN_TYPE, typename CPP_TYPE> |
413 | | requires(std::is_same_v<COLUMN_TYPE, ColumnDecimal128V2>) |
414 | | static Status _fill_fixed_length_column(MutableColumnPtr& doris_column, CPP_TYPE* ptr, |
415 | 0 | size_t num_rows) { |
416 | 0 | auto& column_data = assert_cast<COLUMN_TYPE&>(*doris_column).get_data(); |
417 | 0 | size_t origin_size = column_data.size(); |
418 | 0 | column_data.resize(origin_size + num_rows); |
419 | 0 | for (size_t i = 0; i < num_rows; i++) { |
420 | 0 | column_data[origin_size + i] = DecimalV2Value(ptr[i]); |
421 | 0 | } |
422 | 0 | return Status::OK(); |
423 | 0 | } |
424 | | |
425 | | template <typename COLUMN_TYPE> |
426 | 0 | static long _get_fixed_length_column_address(const IColumn& doris_column) { |
427 | 0 | return (long)assert_cast<const COLUMN_TYPE&>(doris_column).get_data().data(); |
428 | 0 | } Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE3EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE2EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE4EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE5EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE6EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE7EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE8EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE9EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_13ColumnDecimalILNS_13PrimitiveTypeE20EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_13ColumnDecimalILNS_13PrimitiveTypeE30EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_13ColumnDecimalILNS_13PrimitiveTypeE28EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_13ColumnDecimalILNS_13PrimitiveTypeE29EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE11EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE25EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE12EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE26EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE42EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE36EEEEElRKNS_7IColumnE Unexecuted instantiation: _ZN5doris12JniConnector32_get_fixed_length_column_addressINS_12ColumnVectorILNS_13PrimitiveTypeE37EEEEElRKNS_7IColumnE |
429 | | |
430 | | template <PrimitiveType primitive_type> |
431 | | void _parse_value_range(const ColumnValueRange<primitive_type>& col_val_range, |
432 | | const std::string& column_name) { |
433 | | using CppType = std::conditional_t<primitive_type == TYPE_HLL, StringRef, |
434 | | typename PrimitiveTypeTraits<primitive_type>::CppType>; |
435 | | |
436 | | if (col_val_range.is_fixed_value_range()) { |
437 | | ScanPredicate<CppType> in_predicate(column_name); |
438 | | in_predicate.op = SQLFilterOp::FILTER_IN; |
439 | | in_predicate.scale = col_val_range.scale(); |
440 | | for (const auto& value : col_val_range.get_fixed_value_set()) { |
441 | | in_predicate.values.emplace_back(&value); |
442 | | } |
443 | | if (!in_predicate.values.empty()) { |
444 | | _predicates_length = in_predicate.write(_predicates, _predicates_length); |
445 | | } |
446 | | return; |
447 | | } |
448 | | |
449 | | const CppType high_value = col_val_range.get_range_max_value(); |
450 | | const CppType low_value = col_val_range.get_range_min_value(); |
451 | | const SQLFilterOp high_op = col_val_range.get_range_high_op(); |
452 | | const SQLFilterOp low_op = col_val_range.get_range_low_op(); |
453 | | |
454 | | // orc can only push down is_null. When col_value_range._contain_null = true, only indicating that |
455 | | // value can be null, not equals null, so ignore _contain_null in col_value_range |
456 | | if (col_val_range.is_high_value_maximum() && high_op == SQLFilterOp::FILTER_LESS_OR_EQUAL && |
457 | | col_val_range.is_low_value_minimum() && low_op == SQLFilterOp::FILTER_LARGER_OR_EQUAL) { |
458 | | return; |
459 | | } |
460 | | |
461 | | if (low_value < high_value) { |
462 | | if (!col_val_range.is_low_value_minimum() || |
463 | | SQLFilterOp::FILTER_LARGER_OR_EQUAL != low_op) { |
464 | | ScanPredicate<CppType> low_predicate(column_name); |
465 | | low_predicate.scale = col_val_range.scale(); |
466 | | low_predicate.op = low_op; |
467 | | low_predicate.values.emplace_back(col_val_range.get_range_min_value_ptr()); |
468 | | _predicates_length = low_predicate.write(_predicates, _predicates_length); |
469 | | } |
470 | | if (!col_val_range.is_high_value_maximum() || |
471 | | SQLFilterOp::FILTER_LESS_OR_EQUAL != high_op) { |
472 | | ScanPredicate<CppType> high_predicate(column_name); |
473 | | high_predicate.scale = col_val_range.scale(); |
474 | | high_predicate.op = high_op; |
475 | | high_predicate.values.emplace_back(col_val_range.get_range_max_value_ptr()); |
476 | | _predicates_length = high_predicate.write(_predicates, _predicates_length); |
477 | | } |
478 | | } |
479 | | } |
480 | | }; |
481 | | #include "common/compile_check_end.h" |
482 | | } // namespace doris |