be/src/exprs/function/function_string_concat.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 <fmt/format.h> |
21 | | |
22 | | #include <cstddef> |
23 | | #include <cstring> |
24 | | #include <string> |
25 | | #include <string_view> |
26 | | #include <vector> |
27 | | |
28 | | #include "common/status.h" |
29 | | #include "core/assert_cast.h" |
30 | | #include "core/block/block.h" |
31 | | #include "core/block/column_numbers.h" |
32 | | #include "core/column/column.h" |
33 | | #include "core/column/column_array.h" |
34 | | #include "core/column/column_const.h" |
35 | | #include "core/column/column_nullable.h" |
36 | | #include "core/column/column_string.h" |
37 | | #include "core/column/column_vector.h" |
38 | | #include "core/data_type/data_type_array.h" |
39 | | #include "core/data_type/data_type_nullable.h" |
40 | | #include "core/data_type/data_type_number.h" |
41 | | #include "core/data_type/data_type_string.h" |
42 | | #include "core/memcpy_small.h" |
43 | | #include "core/string_ref.h" |
44 | | #include "exec/common/stringop_substring.h" |
45 | | #include "exec/common/template_helpers.hpp" |
46 | | #include "exec/common/util.hpp" |
47 | | #include "exprs/function/function.h" |
48 | | #include "exprs/function/function_helpers.h" |
49 | | #include "exprs/function_context.h" |
50 | | #include "util/simd/vstring_function.h" |
51 | | |
52 | | namespace doris { |
53 | | #include "common/compile_check_avoid_begin.h" |
54 | | |
55 | | class FunctionStringConcat : public IFunction { |
56 | | public: |
57 | | struct ConcatState { |
58 | | bool use_state = false; |
59 | | std::string tail; |
60 | | }; |
61 | | |
62 | | static constexpr auto name = "concat"; |
63 | 2.46k | static FunctionPtr create() { return std::make_shared<FunctionStringConcat>(); } |
64 | 0 | String get_name() const override { return name; } |
65 | 0 | size_t get_number_of_arguments() const override { return 0; } |
66 | 2.45k | bool is_variadic() const override { return true; } |
67 | | |
68 | 2.45k | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
69 | 2.45k | return std::make_shared<DataTypeString>(); |
70 | 2.45k | } |
71 | | |
72 | 8.17k | Status open(FunctionContext* context, FunctionContext::FunctionStateScope scope) override { |
73 | 8.17k | if (scope == FunctionContext::THREAD_LOCAL) { |
74 | 5.71k | return Status::OK(); |
75 | 5.71k | } |
76 | 2.45k | std::shared_ptr<ConcatState> state = std::make_shared<ConcatState>(); |
77 | | |
78 | 2.45k | context->set_function_state(scope, state); |
79 | | |
80 | 2.45k | state->use_state = true; |
81 | | |
82 | | // Optimize function calls like this: |
83 | | // concat(col, "123", "abc", "456") -> tail = "123abc456" |
84 | 4.51k | for (size_t i = 1; i < context->get_num_args(); i++) { |
85 | 4.21k | const auto* column_string = context->get_constant_col(i); |
86 | 4.21k | if (column_string == nullptr) { |
87 | 2.11k | state->use_state = false; |
88 | 2.11k | return IFunction::open(context, scope); |
89 | 2.11k | } |
90 | 2.09k | auto string_vale = column_string->column_ptr->get_data_at(0); |
91 | 2.09k | if (string_vale.data == nullptr) { |
92 | | // For concat(col, null), it is handled by default_implementation_for_nulls |
93 | 33 | state->use_state = false; |
94 | 33 | return IFunction::open(context, scope); |
95 | 33 | } |
96 | | |
97 | 2.06k | state->tail.append(string_vale.begin(), string_vale.size); |
98 | 2.06k | } |
99 | | |
100 | | // The reserve is used here to allow the usage of memcpy_small_allow_read_write_overflow15 below. |
101 | 302 | state->tail.reserve(state->tail.size() + 16); |
102 | | |
103 | 302 | return IFunction::open(context, scope); |
104 | 2.45k | } |
105 | | |
106 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
107 | 2.56k | uint32_t result, size_t input_rows_count) const override { |
108 | 2.56k | DCHECK_GE(arguments.size(), 1); |
109 | | |
110 | 2.56k | if (arguments.size() == 1) { |
111 | 29 | block.get_by_position(result).column = block.get_by_position(arguments[0]).column; |
112 | 29 | return Status::OK(); |
113 | 29 | } |
114 | 2.53k | auto* concat_state = reinterpret_cast<ConcatState*>( |
115 | 2.53k | context->get_function_state(FunctionContext::FRAGMENT_LOCAL)); |
116 | 2.53k | if (!concat_state) { |
117 | 0 | return Status::RuntimeError("funciton context for function '{}' must have ConcatState;", |
118 | 0 | get_name()); |
119 | 0 | } |
120 | 2.53k | if (concat_state->use_state) { |
121 | 287 | const auto& [col, is_const] = |
122 | 287 | unpack_if_const(block.get_by_position(arguments[0]).column); |
123 | 287 | const auto* col_str = assert_cast<const ColumnString*>(col.get()); |
124 | 287 | if (is_const) { |
125 | 0 | return execute_const<true>(concat_state, block, col_str, result, input_rows_count); |
126 | 287 | } else { |
127 | 287 | return execute_const<false>(concat_state, block, col_str, result, input_rows_count); |
128 | 287 | } |
129 | | |
130 | 2.24k | } else { |
131 | 2.24k | return execute_vecotr(block, arguments, result, input_rows_count); |
132 | 2.24k | } |
133 | 2.53k | } |
134 | | |
135 | | Status execute_vecotr(Block& block, const ColumnNumbers& arguments, uint32_t result, |
136 | 2.24k | size_t input_rows_count) const { |
137 | 2.24k | int argument_size = arguments.size(); |
138 | 2.24k | std::vector<ColumnPtr> argument_columns(argument_size); |
139 | | |
140 | 2.24k | std::vector<const ColumnString::Offsets*> offsets_list(argument_size); |
141 | 2.24k | std::vector<const ColumnString::Chars*> chars_list(argument_size); |
142 | 2.24k | std::vector<bool> is_const_args(argument_size); |
143 | | |
144 | 8.76k | for (int i = 0; i < argument_size; ++i) { |
145 | 6.51k | const auto& [col, is_const] = |
146 | 6.51k | unpack_if_const(block.get_by_position(arguments[i]).column); |
147 | | |
148 | 6.51k | const auto* col_str = assert_cast<const ColumnString*>(col.get()); |
149 | 6.51k | offsets_list[i] = &col_str->get_offsets(); |
150 | 6.51k | chars_list[i] = &col_str->get_chars(); |
151 | 6.51k | is_const_args[i] = is_const; |
152 | 6.51k | } |
153 | | |
154 | 2.24k | auto res = ColumnString::create(); |
155 | 2.24k | auto& res_data = res->get_chars(); |
156 | 2.24k | auto& res_offset = res->get_offsets(); |
157 | | |
158 | 2.24k | res_offset.resize(input_rows_count); |
159 | 2.24k | size_t res_reserve_size = 0; |
160 | 8.76k | for (size_t i = 0; i < argument_size; ++i) { |
161 | 6.51k | if (is_const_args[i]) { |
162 | 2.13k | res_reserve_size += (*offsets_list[i])[0] * input_rows_count; |
163 | 4.37k | } else { |
164 | 4.37k | res_reserve_size += (*offsets_list[i])[input_rows_count - 1]; |
165 | 4.37k | } |
166 | 6.51k | } |
167 | | |
168 | 2.24k | ColumnString::check_chars_length(res_reserve_size, 0); |
169 | | |
170 | 2.24k | res_data.resize(res_reserve_size); |
171 | | |
172 | 2.24k | auto* data = res_data.data(); |
173 | 2.24k | size_t dst_offset = 0; |
174 | | |
175 | 71.8k | for (size_t i = 0; i < input_rows_count; ++i) { |
176 | 209k | for (size_t j = 0; j < argument_size; ++j) { |
177 | 139k | const auto& current_offsets = *offsets_list[j]; |
178 | 139k | const auto& current_chars = *chars_list[j]; |
179 | 139k | auto idx = index_check_const(i, is_const_args[j]); |
180 | 139k | const auto size = current_offsets[idx] - current_offsets[idx - 1]; |
181 | 139k | if (size > 0) { |
182 | 139k | memcpy_small_allow_read_write_overflow15( |
183 | 139k | data + dst_offset, current_chars.data() + current_offsets[idx - 1], |
184 | 139k | size); |
185 | 139k | dst_offset += size; |
186 | 139k | } |
187 | 139k | } |
188 | 69.5k | res_offset[i] = dst_offset; |
189 | 69.5k | } |
190 | | |
191 | 2.24k | block.get_by_position(result).column = std::move(res); |
192 | 2.24k | return Status::OK(); |
193 | 2.24k | } |
194 | | |
195 | | template <bool is_const> |
196 | | Status execute_const(ConcatState* concat_state, Block& block, const ColumnString* col_str, |
197 | 286 | uint32_t result, size_t input_rows_count) const { |
198 | | // using tail optimize |
199 | | |
200 | 286 | auto res = ColumnString::create(); |
201 | 286 | auto& res_data = res->get_chars(); |
202 | 286 | auto& res_offset = res->get_offsets(); |
203 | 286 | res_offset.resize(input_rows_count); |
204 | | |
205 | 286 | size_t res_reserve_size = 0; |
206 | 286 | if constexpr (is_const) { |
207 | 0 | res_reserve_size = col_str->get_offsets()[0] * input_rows_count; |
208 | 286 | } else { |
209 | 286 | res_reserve_size = col_str->get_offsets()[input_rows_count - 1]; |
210 | 286 | } |
211 | 286 | res_reserve_size += concat_state->tail.size() * input_rows_count; |
212 | | |
213 | 286 | ColumnString::check_chars_length(res_reserve_size, 0); |
214 | 286 | res_data.resize(res_reserve_size); |
215 | | |
216 | 286 | const auto& tail = concat_state->tail; |
217 | 286 | auto* data = res_data.data(); |
218 | 286 | size_t dst_offset = 0; |
219 | | |
220 | 920 | for (size_t i = 0; i < input_rows_count; ++i) { |
221 | 634 | const auto idx = index_check_const<is_const>(i); |
222 | 634 | StringRef str_val = col_str->get_data_at(idx); |
223 | | // copy column |
224 | 634 | memcpy_small_allow_read_write_overflow15(data + dst_offset, str_val.data, str_val.size); |
225 | 634 | dst_offset += str_val.size; |
226 | | // copy tail |
227 | 634 | memcpy_small_allow_read_write_overflow15(data + dst_offset, tail.data(), tail.size()); |
228 | 634 | dst_offset += tail.size(); |
229 | 634 | res_offset[i] = dst_offset; |
230 | 634 | } |
231 | 286 | block.get_by_position(result).column = std::move(res); |
232 | 286 | return Status::OK(); |
233 | 286 | } Unexecuted instantiation: _ZNK5doris20FunctionStringConcat13execute_constILb1EEENS_6StatusEPNS0_11ConcatStateERNS_5BlockEPKNS_9ColumnStrIjEEjm _ZNK5doris20FunctionStringConcat13execute_constILb0EEENS_6StatusEPNS0_11ConcatStateERNS_5BlockEPKNS_9ColumnStrIjEEjm Line | Count | Source | 197 | 286 | uint32_t result, size_t input_rows_count) const { | 198 | | // using tail optimize | 199 | | | 200 | 286 | auto res = ColumnString::create(); | 201 | 286 | auto& res_data = res->get_chars(); | 202 | 286 | auto& res_offset = res->get_offsets(); | 203 | 286 | res_offset.resize(input_rows_count); | 204 | | | 205 | 286 | size_t res_reserve_size = 0; | 206 | | if constexpr (is_const) { | 207 | | res_reserve_size = col_str->get_offsets()[0] * input_rows_count; | 208 | 286 | } else { | 209 | 286 | res_reserve_size = col_str->get_offsets()[input_rows_count - 1]; | 210 | 286 | } | 211 | 286 | res_reserve_size += concat_state->tail.size() * input_rows_count; | 212 | | | 213 | 286 | ColumnString::check_chars_length(res_reserve_size, 0); | 214 | 286 | res_data.resize(res_reserve_size); | 215 | | | 216 | 286 | const auto& tail = concat_state->tail; | 217 | 286 | auto* data = res_data.data(); | 218 | 286 | size_t dst_offset = 0; | 219 | | | 220 | 920 | for (size_t i = 0; i < input_rows_count; ++i) { | 221 | 634 | const auto idx = index_check_const<is_const>(i); | 222 | 634 | StringRef str_val = col_str->get_data_at(idx); | 223 | | // copy column | 224 | 634 | memcpy_small_allow_read_write_overflow15(data + dst_offset, str_val.data, str_val.size); | 225 | 634 | dst_offset += str_val.size; | 226 | | // copy tail | 227 | 634 | memcpy_small_allow_read_write_overflow15(data + dst_offset, tail.data(), tail.size()); | 228 | 634 | dst_offset += tail.size(); | 229 | 634 | res_offset[i] = dst_offset; | 230 | 634 | } | 231 | 286 | block.get_by_position(result).column = std::move(res); | 232 | 286 | return Status::OK(); | 233 | 286 | } |
|
234 | | }; |
235 | | |
236 | | class FunctionStringElt : public IFunction { |
237 | | public: |
238 | | static constexpr auto name = "elt"; |
239 | 423 | static FunctionPtr create() { return std::make_shared<FunctionStringElt>(); } |
240 | 0 | String get_name() const override { return name; } |
241 | 0 | size_t get_number_of_arguments() const override { return 0; } |
242 | 415 | bool is_variadic() const override { return true; } |
243 | | |
244 | 414 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
245 | 414 | return make_nullable(std::make_shared<DataTypeString>()); |
246 | 414 | } |
247 | 840 | bool use_default_implementation_for_nulls() const override { return false; } |
248 | | |
249 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
250 | 426 | uint32_t result, size_t input_rows_count) const override { |
251 | 426 | int arguent_size = arguments.size(); |
252 | 426 | int num_children = arguent_size - 1; |
253 | 426 | auto res = ColumnString::create(); |
254 | | |
255 | 426 | if (auto const_column = check_and_get_column<ColumnConst>( |
256 | 426 | *block.get_by_position(arguments[0]).column)) { |
257 | 154 | auto data = const_column->get_data_at(0); |
258 | | // return NULL, pos is null or pos < 0 or pos > num_children |
259 | 154 | auto is_null = data.data == nullptr; |
260 | 154 | auto pos = is_null ? 0 : *(Int32*)data.data; |
261 | 154 | is_null = pos <= 0 || pos > num_children; |
262 | | |
263 | 154 | auto null_map = ColumnUInt8::create(input_rows_count, is_null); |
264 | 154 | if (is_null) { |
265 | 135 | res->insert_many_defaults(input_rows_count); |
266 | 135 | } else { |
267 | 19 | auto& target_column = block.get_by_position(arguments[pos]).column; |
268 | 19 | if (auto target_const_column = check_and_get_column<ColumnConst>(*target_column)) { |
269 | 7 | auto target_data = target_const_column->get_data_at(0); |
270 | | // return NULL, no target data |
271 | 7 | if (target_data.data == nullptr) { |
272 | 1 | null_map = ColumnUInt8::create(input_rows_count, true); |
273 | 1 | res->insert_many_defaults(input_rows_count); |
274 | 6 | } else { |
275 | 6 | res->insert_data_repeatedly(target_data.data, target_data.size, |
276 | 6 | input_rows_count); |
277 | 6 | } |
278 | 12 | } else if (auto target_nullable_column = |
279 | 12 | check_and_get_column<ColumnNullable>(*target_column)) { |
280 | 12 | auto& target_null_map = target_nullable_column->get_null_map_data(); |
281 | 12 | VectorizedUtils::update_null_map( |
282 | 12 | assert_cast<ColumnUInt8&>(*null_map).get_data(), target_null_map); |
283 | | |
284 | 12 | auto& target_str_column = assert_cast<const ColumnString&>( |
285 | 12 | target_nullable_column->get_nested_column()); |
286 | 12 | res->get_chars().assign(target_str_column.get_chars().begin(), |
287 | 12 | target_str_column.get_chars().end()); |
288 | 12 | res->get_offsets().assign(target_str_column.get_offsets().begin(), |
289 | 12 | target_str_column.get_offsets().end()); |
290 | 12 | } else { |
291 | 0 | auto& target_str_column = assert_cast<const ColumnString&>(*target_column); |
292 | 0 | res->get_chars().assign(target_str_column.get_chars().begin(), |
293 | 0 | target_str_column.get_chars().end()); |
294 | 0 | res->get_offsets().assign(target_str_column.get_offsets().begin(), |
295 | 0 | target_str_column.get_offsets().end()); |
296 | 0 | } |
297 | 19 | } |
298 | 154 | block.get_by_position(result).column = |
299 | 154 | ColumnNullable::create(std::move(res), std::move(null_map)); |
300 | 272 | } else if (auto pos_null_column = check_and_get_column<ColumnNullable>( |
301 | 272 | *block.get_by_position(arguments[0]).column)) { |
302 | 219 | auto& pos_column = |
303 | 219 | assert_cast<const ColumnInt32&>(pos_null_column->get_nested_column()); |
304 | 219 | auto& pos_null_map = pos_null_column->get_null_map_data(); |
305 | 219 | auto null_map = ColumnUInt8::create(input_rows_count, false); |
306 | 219 | auto& res_null_map = assert_cast<ColumnUInt8&>(*null_map).get_data(); |
307 | | |
308 | 515 | for (size_t i = 0; i < input_rows_count; ++i) { |
309 | 296 | auto pos = pos_column.get_element(i); |
310 | 296 | res_null_map[i] = |
311 | 296 | pos_null_map[i] || pos <= 0 || pos > num_children || |
312 | 296 | block.get_by_position(arguments[pos]).column->get_data_at(i).data == |
313 | 35 | nullptr; |
314 | 296 | if (res_null_map[i]) { |
315 | 261 | res->insert_default(); |
316 | 261 | } else { |
317 | 35 | auto insert_data = block.get_by_position(arguments[pos]).column->get_data_at(i); |
318 | 35 | res->insert_data(insert_data.data, insert_data.size); |
319 | 35 | } |
320 | 296 | } |
321 | 219 | block.get_by_position(result).column = |
322 | 219 | ColumnNullable::create(std::move(res), std::move(null_map)); |
323 | 219 | } else { |
324 | 53 | auto& pos_column = |
325 | 53 | assert_cast<const ColumnInt32&>(*block.get_by_position(arguments[0]).column); |
326 | 53 | auto null_map = ColumnUInt8::create(input_rows_count, false); |
327 | 53 | auto& res_null_map = assert_cast<ColumnUInt8&>(*null_map).get_data(); |
328 | | |
329 | 122 | for (size_t i = 0; i < input_rows_count; ++i) { |
330 | 69 | auto pos = pos_column.get_element(i); |
331 | 69 | res_null_map[i] = |
332 | 69 | pos <= 0 || pos > num_children || |
333 | 69 | block.get_by_position(arguments[pos]).column->get_data_at(i).data == |
334 | 23 | nullptr; |
335 | 69 | if (res_null_map[i]) { |
336 | 46 | res->insert_default(); |
337 | 46 | } else { |
338 | 23 | auto insert_data = block.get_by_position(arguments[pos]).column->get_data_at(i); |
339 | 23 | res->insert_data(insert_data.data, insert_data.size); |
340 | 23 | } |
341 | 69 | } |
342 | 53 | block.get_by_position(result).column = |
343 | 53 | ColumnNullable::create(std::move(res), std::move(null_map)); |
344 | 53 | } |
345 | 426 | return Status::OK(); |
346 | 426 | } |
347 | | }; |
348 | | |
349 | | // concat_ws (string,string....) or (string, Array) |
350 | | // TODO: avoid use fmtlib |
351 | | class FunctionStringConcatWs : public IFunction { |
352 | | public: |
353 | | using Chars = ColumnString::Chars; |
354 | | using Offsets = ColumnString::Offsets; |
355 | | |
356 | | static constexpr auto name = "concat_ws"; |
357 | 553 | static FunctionPtr create() { return std::make_shared<FunctionStringConcatWs>(); } |
358 | 0 | String get_name() const override { return name; } |
359 | 0 | size_t get_number_of_arguments() const override { return 0; } |
360 | 545 | bool is_variadic() const override { return true; } |
361 | | |
362 | 544 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
363 | 544 | const IDataType* first_type = arguments[0].get(); |
364 | 544 | if (first_type->is_nullable()) { |
365 | 458 | return make_nullable(std::make_shared<DataTypeString>()); |
366 | 458 | } else { |
367 | 86 | return std::make_shared<DataTypeString>(); |
368 | 86 | } |
369 | 544 | } |
370 | 1.11k | bool use_default_implementation_for_nulls() const override { return false; } |
371 | | |
372 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
373 | 566 | uint32_t result, size_t input_rows_count) const override { |
374 | 566 | DCHECK_GE(arguments.size(), 2); |
375 | 566 | auto null_map = ColumnUInt8::create(input_rows_count, 0); |
376 | | // we create a zero column to simply implement |
377 | 566 | auto const_null_map = ColumnUInt8::create(input_rows_count, 0); |
378 | 566 | auto res = ColumnString::create(); |
379 | 566 | bool is_null_type = block.get_by_position(arguments[0]).type.get()->is_nullable(); |
380 | 566 | size_t argument_size = arguments.size(); |
381 | 566 | std::vector<const Offsets*> offsets_list(argument_size); |
382 | 566 | std::vector<const Chars*> chars_list(argument_size); |
383 | 566 | std::vector<const ColumnUInt8::Container*> null_list(argument_size); |
384 | | |
385 | 566 | std::vector<ColumnPtr> argument_columns(argument_size); |
386 | 566 | std::vector<ColumnPtr> argument_null_columns(argument_size); |
387 | | |
388 | 1.94k | for (size_t i = 0; i < argument_size; ++i) { |
389 | 1.38k | argument_columns[i] = |
390 | 1.38k | block.get_by_position(arguments[i]).column->convert_to_full_column_if_const(); |
391 | 1.38k | if (const auto* nullable = |
392 | 1.38k | check_and_get_column<const ColumnNullable>(*argument_columns[i])) { |
393 | | // Danger: Here must dispose the null map data first! Because |
394 | | // argument_columns[i]=nullable->get_nested_column_ptr(); will release the mem |
395 | | // of column nullable mem of null map |
396 | 1.13k | null_list[i] = &nullable->get_null_map_data(); |
397 | 1.13k | argument_null_columns[i] = nullable->get_null_map_column_ptr(); |
398 | 1.13k | argument_columns[i] = nullable->get_nested_column_ptr(); |
399 | 1.13k | } else { |
400 | 244 | null_list[i] = &const_null_map->get_data(); |
401 | 244 | } |
402 | | |
403 | 1.38k | if (is_column<ColumnArray>(argument_columns[i].get())) { |
404 | 101 | continue; |
405 | 101 | } |
406 | | |
407 | 1.28k | const auto* col_str = assert_cast<const ColumnString*>(argument_columns[i].get()); |
408 | 1.28k | offsets_list[i] = &col_str->get_offsets(); |
409 | 1.28k | chars_list[i] = &col_str->get_chars(); |
410 | 1.28k | } |
411 | | |
412 | 566 | auto& res_data = res->get_chars(); |
413 | 566 | auto& res_offset = res->get_offsets(); |
414 | 566 | res_offset.resize(input_rows_count); |
415 | | |
416 | 566 | VectorizedUtils::update_null_map(null_map->get_data(), *null_list[0]); |
417 | 566 | fmt::memory_buffer buffer; |
418 | 566 | std::vector<std::string_view> views; |
419 | | |
420 | 566 | if (is_column<ColumnArray>(argument_columns[1].get())) { |
421 | | // Determine if the nested type of the array is String |
422 | 101 | const auto& array_column = reinterpret_cast<const ColumnArray&>(*argument_columns[1]); |
423 | 101 | if (!array_column.get_data().is_column_string()) { |
424 | 0 | return Status::NotSupported( |
425 | 0 | fmt::format("unsupported nested array of type {} for function {}", |
426 | 0 | is_column_nullable(array_column.get_data()) |
427 | 0 | ? array_column.get_data().get_name() |
428 | 0 | : array_column.get_data().get_name(), |
429 | 0 | get_name())); |
430 | 0 | } |
431 | | // Concat string in array |
432 | 101 | _execute_array(input_rows_count, array_column, buffer, views, offsets_list, chars_list, |
433 | 101 | null_list, res_data, res_offset); |
434 | | |
435 | 465 | } else { |
436 | | // Concat string |
437 | 465 | _execute_string(input_rows_count, argument_size, buffer, views, offsets_list, |
438 | 465 | chars_list, null_list, res_data, res_offset); |
439 | 465 | } |
440 | 566 | if (is_null_type) { |
441 | 458 | block.get_by_position(result).column = |
442 | 458 | ColumnNullable::create(std::move(res), std::move(null_map)); |
443 | 458 | } else { |
444 | 108 | block.get_by_position(result).column = std::move(res); |
445 | 108 | } |
446 | 566 | return Status::OK(); |
447 | 566 | } |
448 | | |
449 | | private: |
450 | | void _execute_array(const size_t& input_rows_count, const ColumnArray& array_column, |
451 | | fmt::memory_buffer& buffer, std::vector<std::string_view>& views, |
452 | | const std::vector<const Offsets*>& offsets_list, |
453 | | const std::vector<const Chars*>& chars_list, |
454 | | const std::vector<const ColumnUInt8::Container*>& null_list, |
455 | 101 | Chars& res_data, Offsets& res_offset) const { |
456 | | // Get array nested column |
457 | 101 | const UInt8* array_nested_null_map = nullptr; |
458 | 101 | ColumnPtr array_nested_column = nullptr; |
459 | | |
460 | 101 | if (is_column_nullable(array_column.get_data())) { |
461 | 101 | const auto& array_nested_null_column = |
462 | 101 | reinterpret_cast<const ColumnNullable&>(array_column.get_data()); |
463 | | // String's null map in array |
464 | 101 | array_nested_null_map = |
465 | 101 | array_nested_null_column.get_null_map_column().get_data().data(); |
466 | 101 | array_nested_column = array_nested_null_column.get_nested_column_ptr(); |
467 | 101 | } else { |
468 | 0 | array_nested_column = array_column.get_data_ptr(); |
469 | 0 | } |
470 | | |
471 | 101 | const auto& string_column = reinterpret_cast<const ColumnString&>(*array_nested_column); |
472 | 101 | const Chars& string_src_chars = string_column.get_chars(); |
473 | 101 | const auto& src_string_offsets = string_column.get_offsets(); |
474 | 101 | const auto& src_array_offsets = array_column.get_offsets(); |
475 | 101 | size_t current_src_array_offset = 0; |
476 | | |
477 | | // Concat string in array |
478 | 601 | for (size_t i = 0; i < input_rows_count; ++i) { |
479 | 500 | auto& sep_offsets = *offsets_list[0]; |
480 | 500 | auto& sep_chars = *chars_list[0]; |
481 | 500 | auto& sep_nullmap = *null_list[0]; |
482 | | |
483 | 500 | if (sep_nullmap[i]) { |
484 | 11 | res_offset[i] = res_data.size(); |
485 | 11 | current_src_array_offset += src_array_offsets[i] - src_array_offsets[i - 1]; |
486 | 11 | continue; |
487 | 11 | } |
488 | | |
489 | 489 | int sep_size = sep_offsets[i] - sep_offsets[i - 1]; |
490 | 489 | const char* sep_data = reinterpret_cast<const char*>(&sep_chars[sep_offsets[i - 1]]); |
491 | | |
492 | 489 | std::string_view sep(sep_data, sep_size); |
493 | 489 | buffer.clear(); |
494 | 489 | views.clear(); |
495 | | |
496 | 489 | for (auto next_src_array_offset = src_array_offsets[i]; |
497 | 1.28k | current_src_array_offset < next_src_array_offset; ++current_src_array_offset) { |
498 | 800 | const auto current_src_string_offset = |
499 | 800 | current_src_array_offset ? src_string_offsets[current_src_array_offset - 1] |
500 | 800 | : 0; |
501 | 800 | size_t bytes_to_copy = |
502 | 800 | src_string_offsets[current_src_array_offset] - current_src_string_offset; |
503 | 800 | const char* ptr = |
504 | 800 | reinterpret_cast<const char*>(&string_src_chars[current_src_string_offset]); |
505 | | |
506 | 800 | if (array_nested_null_map == nullptr || |
507 | 800 | !array_nested_null_map[current_src_array_offset]) { |
508 | 771 | views.emplace_back(ptr, bytes_to_copy); |
509 | 771 | } |
510 | 800 | } |
511 | | |
512 | 489 | fmt::format_to(buffer, "{}", fmt::join(views, sep)); |
513 | | |
514 | 489 | StringOP::push_value_string(std::string_view(buffer.data(), buffer.size()), i, res_data, |
515 | 489 | res_offset); |
516 | 489 | } |
517 | 101 | } |
518 | | |
519 | | void _execute_string(const size_t& input_rows_count, const size_t& argument_size, |
520 | | fmt::memory_buffer& buffer, std::vector<std::string_view>& views, |
521 | | const std::vector<const Offsets*>& offsets_list, |
522 | | const std::vector<const Chars*>& chars_list, |
523 | | const std::vector<const ColumnUInt8::Container*>& null_list, |
524 | 465 | Chars& res_data, Offsets& res_offset) const { |
525 | | // Concat string |
526 | 1.08k | for (size_t i = 0; i < input_rows_count; ++i) { |
527 | 620 | auto& sep_offsets = *offsets_list[0]; |
528 | 620 | auto& sep_chars = *chars_list[0]; |
529 | 620 | auto& sep_nullmap = *null_list[0]; |
530 | 620 | if (sep_nullmap[i]) { |
531 | 78 | res_offset[i] = res_data.size(); |
532 | 78 | continue; |
533 | 78 | } |
534 | | |
535 | 542 | int sep_size = sep_offsets[i] - sep_offsets[i - 1]; |
536 | 542 | const char* sep_data = reinterpret_cast<const char*>(&sep_chars[sep_offsets[i - 1]]); |
537 | | |
538 | 542 | std::string_view sep(sep_data, sep_size); |
539 | 542 | buffer.clear(); |
540 | 542 | views.clear(); |
541 | 1.30k | for (size_t j = 1; j < argument_size; ++j) { |
542 | 764 | auto& current_offsets = *offsets_list[j]; |
543 | 764 | auto& current_chars = *chars_list[j]; |
544 | 764 | auto& current_nullmap = *null_list[j]; |
545 | 764 | int size = current_offsets[i] - current_offsets[i - 1]; |
546 | 764 | const char* ptr = |
547 | 764 | reinterpret_cast<const char*>(¤t_chars[current_offsets[i - 1]]); |
548 | 764 | if (!current_nullmap[i]) { |
549 | 688 | views.emplace_back(ptr, size); |
550 | 688 | } |
551 | 764 | } |
552 | 542 | fmt::format_to(buffer, "{}", fmt::join(views, sep)); |
553 | 542 | StringOP::push_value_string(std::string_view(buffer.data(), buffer.size()), i, res_data, |
554 | 542 | res_offset); |
555 | 542 | } |
556 | 465 | } |
557 | | }; |
558 | | |
559 | | class FunctionStringRepeat : public IFunction { |
560 | | public: |
561 | | static constexpr auto name = "repeat"; |
562 | 237 | static FunctionPtr create() { return std::make_shared<FunctionStringRepeat>(); } |
563 | 1 | String get_name() const override { return name; } |
564 | 228 | size_t get_number_of_arguments() const override { return 2; } |
565 | | // should set NULL value of nested data to default, |
566 | | // as iff it's not inited and invalid, the repeat result of length is so large cause overflow |
567 | 235 | bool need_replace_null_data_to_default() const override { return true; } |
568 | | |
569 | 228 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
570 | 228 | return make_nullable(std::make_shared<DataTypeString>()); |
571 | 228 | } |
572 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
573 | 271 | uint32_t result, size_t input_rows_count) const override { |
574 | 271 | DCHECK_EQ(arguments.size(), 2); |
575 | 271 | auto res = ColumnString::create(); |
576 | 271 | auto null_map = ColumnUInt8::create(); |
577 | | |
578 | 271 | ColumnPtr argument_ptr[2]; |
579 | 271 | argument_ptr[0] = |
580 | 271 | block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); |
581 | 271 | argument_ptr[1] = block.get_by_position(arguments[1]).column; |
582 | | |
583 | 271 | if (const auto* col1 = check_and_get_column<ColumnString>(*argument_ptr[0])) { |
584 | 271 | if (const auto* col2 = check_and_get_column<ColumnInt32>(*argument_ptr[1])) { |
585 | 151 | RETURN_IF_ERROR(vector_vector(col1->get_chars(), col1->get_offsets(), |
586 | 151 | col2->get_data(), res->get_chars(), |
587 | 151 | res->get_offsets(), null_map->get_data())); |
588 | 151 | block.replace_by_position( |
589 | 151 | result, ColumnNullable::create(std::move(res), std::move(null_map))); |
590 | 151 | return Status::OK(); |
591 | 151 | } else if (const auto* col2_const = |
592 | 120 | check_and_get_column<ColumnConst>(*argument_ptr[1])) { |
593 | 120 | DCHECK(check_and_get_column<ColumnInt32>(col2_const->get_data_column())); |
594 | 120 | int repeat = col2_const->get_int(0); |
595 | 120 | if (repeat <= 0) { |
596 | 18 | null_map->get_data().resize_fill(input_rows_count, 0); |
597 | 18 | res->insert_many_defaults(input_rows_count); |
598 | 102 | } else { |
599 | 102 | vector_const(col1->get_chars(), col1->get_offsets(), repeat, res->get_chars(), |
600 | 102 | res->get_offsets(), null_map->get_data()); |
601 | 102 | } |
602 | 120 | block.replace_by_position( |
603 | 120 | result, ColumnNullable::create(std::move(res), std::move(null_map))); |
604 | 120 | return Status::OK(); |
605 | 120 | } |
606 | 271 | } |
607 | | |
608 | 0 | return Status::RuntimeError("repeat function get error param: {}, {}", |
609 | 0 | argument_ptr[0]->get_name(), argument_ptr[1]->get_name()); |
610 | 271 | } |
611 | | |
612 | | Status vector_vector(const ColumnString::Chars& data, const ColumnString::Offsets& offsets, |
613 | | const ColumnInt32::Container& repeats, ColumnString::Chars& res_data, |
614 | | ColumnString::Offsets& res_offsets, |
615 | 151 | ColumnUInt8::Container& null_map) const { |
616 | 151 | size_t input_row_size = offsets.size(); |
617 | | |
618 | 151 | fmt::memory_buffer buffer; |
619 | 151 | res_offsets.resize(input_row_size); |
620 | 151 | null_map.resize_fill(input_row_size, 0); |
621 | 395 | for (ssize_t i = 0; i < input_row_size; ++i) { |
622 | 244 | buffer.clear(); |
623 | 244 | const char* raw_str = reinterpret_cast<const char*>(&data[offsets[i - 1]]); |
624 | 244 | size_t size = offsets[i] - offsets[i - 1]; |
625 | 244 | int repeat = repeats[i]; |
626 | 244 | if (repeat <= 0) { |
627 | 66 | StringOP::push_empty_string(i, res_data, res_offsets); |
628 | 178 | } else { |
629 | 178 | ColumnString::check_chars_length(repeat * size + res_data.size(), 0); |
630 | 132k | for (int j = 0; j < repeat; ++j) { |
631 | 131k | buffer.append(raw_str, raw_str + size); |
632 | 131k | } |
633 | 178 | StringOP::push_value_string(std::string_view(buffer.data(), buffer.size()), i, |
634 | 178 | res_data, res_offsets); |
635 | 178 | } |
636 | 244 | } |
637 | 151 | return Status::OK(); |
638 | 151 | } |
639 | | |
640 | | // TODO: 1. use pmr::vector<char> replace fmt_buffer may speed up the code |
641 | | // 2. abstract the `vector_vector` and `vector_const` |
642 | | // 3. rethink we should use `DEFAULT_MAX_STRING_SIZE` to bigger here |
643 | | void vector_const(const ColumnString::Chars& data, const ColumnString::Offsets& offsets, |
644 | | int repeat, ColumnString::Chars& res_data, ColumnString::Offsets& res_offsets, |
645 | 102 | ColumnUInt8::Container& null_map) const { |
646 | 102 | size_t input_row_size = offsets.size(); |
647 | | |
648 | 102 | fmt::memory_buffer buffer; |
649 | 102 | res_offsets.resize(input_row_size); |
650 | 102 | null_map.resize_fill(input_row_size, 0); |
651 | 4.30k | for (ssize_t i = 0; i < input_row_size; ++i) { |
652 | 4.20k | buffer.clear(); |
653 | 4.20k | const char* raw_str = reinterpret_cast<const char*>(&data[offsets[i - 1]]); |
654 | 4.20k | size_t size = offsets[i] - offsets[i - 1]; |
655 | 4.20k | ColumnString::check_chars_length(repeat * size + res_data.size(), 0); |
656 | | |
657 | 44.5k | for (int j = 0; j < repeat; ++j) { |
658 | 40.3k | buffer.append(raw_str, raw_str + size); |
659 | 40.3k | } |
660 | 4.20k | StringOP::push_value_string(std::string_view(buffer.data(), buffer.size()), i, res_data, |
661 | 4.20k | res_offsets); |
662 | 4.20k | } |
663 | 102 | } |
664 | | }; |
665 | | |
666 | | template <typename Impl> |
667 | | class FunctionStringPad : public IFunction { |
668 | | public: |
669 | | static constexpr auto name = Impl::name; |
670 | 1.87k | static FunctionPtr create() { return std::make_shared<FunctionStringPad>(); }_ZN5doris17FunctionStringPadINS_10StringLPadEE6createEv Line | Count | Source | 670 | 1.09k | static FunctionPtr create() { return std::make_shared<FunctionStringPad>(); } |
_ZN5doris17FunctionStringPadINS_10StringRPadEE6createEv Line | Count | Source | 670 | 773 | static FunctionPtr create() { return std::make_shared<FunctionStringPad>(); } |
|
671 | 2 | String get_name() const override { return name; }_ZNK5doris17FunctionStringPadINS_10StringLPadEE8get_nameB5cxx11Ev Line | Count | Source | 671 | 1 | String get_name() const override { return name; } |
_ZNK5doris17FunctionStringPadINS_10StringRPadEE8get_nameB5cxx11Ev Line | Count | Source | 671 | 1 | String get_name() const override { return name; } |
|
672 | 1.85k | size_t get_number_of_arguments() const override { return 3; }_ZNK5doris17FunctionStringPadINS_10StringLPadEE23get_number_of_argumentsEv Line | Count | Source | 672 | 1.08k | size_t get_number_of_arguments() const override { return 3; } |
_ZNK5doris17FunctionStringPadINS_10StringRPadEE23get_number_of_argumentsEv Line | Count | Source | 672 | 764 | size_t get_number_of_arguments() const override { return 3; } |
|
673 | | |
674 | 1.85k | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
675 | 1.85k | return make_nullable(std::make_shared<DataTypeString>()); |
676 | 1.85k | } _ZNK5doris17FunctionStringPadINS_10StringLPadEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE Line | Count | Source | 674 | 1.08k | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | 675 | 1.08k | return make_nullable(std::make_shared<DataTypeString>()); | 676 | 1.08k | } |
_ZNK5doris17FunctionStringPadINS_10StringRPadEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE Line | Count | Source | 674 | 764 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | 675 | 764 | return make_nullable(std::make_shared<DataTypeString>()); | 676 | 764 | } |
|
677 | | |
678 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
679 | 1.37k | uint32_t result, size_t input_rows_count) const override { |
680 | 1.37k | DCHECK_GE(arguments.size(), 3); |
681 | 1.37k | auto null_map = ColumnUInt8::create(input_rows_count, 0); |
682 | | // we create a zero column to simply implement |
683 | 1.37k | auto const_null_map = ColumnUInt8::create(input_rows_count, 0); |
684 | 1.37k | auto res = ColumnString::create(); |
685 | | |
686 | 1.37k | ColumnPtr col[3]; |
687 | 1.37k | bool col_const[3]; |
688 | 5.50k | for (size_t i = 0; i < 3; ++i) { |
689 | 4.12k | std::tie(col[i], col_const[i]) = |
690 | 4.12k | unpack_if_const(block.get_by_position(arguments[i]).column); |
691 | 4.12k | } |
692 | 1.37k | auto& null_map_data = null_map->get_data(); |
693 | 1.37k | auto& res_offsets = res->get_offsets(); |
694 | 1.37k | auto& res_chars = res->get_chars(); |
695 | 1.37k | res_offsets.resize(input_rows_count); |
696 | | |
697 | 1.37k | const auto* strcol = assert_cast<const ColumnString*>(col[0].get()); |
698 | 1.37k | const auto& strcol_offsets = strcol->get_offsets(); |
699 | 1.37k | const auto& strcol_chars = strcol->get_chars(); |
700 | | |
701 | 1.37k | const auto* col_len = assert_cast<const ColumnInt32*>(col[1].get()); |
702 | 1.37k | const auto& col_len_data = col_len->get_data(); |
703 | | |
704 | 1.37k | const auto* padcol = assert_cast<const ColumnString*>(col[2].get()); |
705 | 1.37k | const auto& padcol_offsets = padcol->get_offsets(); |
706 | 1.37k | const auto& padcol_chars = padcol->get_chars(); |
707 | 1.37k | std::visit( |
708 | 1.37k | [&](auto str_const, auto len_const, auto pad_const) { |
709 | 1.37k | execute_utf8<str_const, len_const, pad_const>( |
710 | 1.37k | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, |
711 | 1.37k | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); |
712 | 1.37k | }, _ZZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb0EESI_SI_EEDaSC_SD_SE_ Line | Count | Source | 708 | 465 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 465 | execute_utf8<str_const, len_const, pad_const>( | 710 | 465 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 465 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 465 | }, |
_ZZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb0EESI_SH_IbLb1EEEEDaSC_SD_SE_ Line | Count | Source | 708 | 62 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 62 | execute_utf8<str_const, len_const, pad_const>( | 710 | 62 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 62 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 62 | }, |
_ZZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb0EESH_IbLb1EESI_EEDaSC_SD_SE_ Line | Count | Source | 708 | 62 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 62 | execute_utf8<str_const, len_const, pad_const>( | 710 | 62 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 62 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 62 | }, |
_ZZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb0EESH_IbLb1EESJ_EEDaSC_SD_SE_ Line | Count | Source | 708 | 73 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 73 | execute_utf8<str_const, len_const, pad_const>( | 710 | 73 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 73 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 73 | }, |
_ZZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb1EESH_IbLb0EESJ_EEDaSC_SD_SE_ Line | Count | Source | 708 | 62 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 62 | execute_utf8<str_const, len_const, pad_const>( | 710 | 62 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 62 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 62 | }, |
_ZZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb1EESH_IbLb0EESI_EEDaSC_SD_SE_ Line | Count | Source | 708 | 62 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 62 | execute_utf8<str_const, len_const, pad_const>( | 710 | 62 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 62 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 62 | }, |
_ZZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb1EESI_SH_IbLb0EEEEDaSC_SD_SE_ Line | Count | Source | 708 | 62 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 62 | execute_utf8<str_const, len_const, pad_const>( | 710 | 62 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 62 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 62 | }, |
Unexecuted instantiation: _ZZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb1EESI_SI_EEDaSC_SD_SE_ _ZZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb0EESI_SI_EEDaSC_SD_SE_ Line | Count | Source | 708 | 151 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 151 | execute_utf8<str_const, len_const, pad_const>( | 710 | 151 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 151 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 151 | }, |
_ZZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb0EESI_SH_IbLb1EEEEDaSC_SD_SE_ Line | Count | Source | 708 | 62 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 62 | execute_utf8<str_const, len_const, pad_const>( | 710 | 62 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 62 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 62 | }, |
_ZZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb0EESH_IbLb1EESI_EEDaSC_SD_SE_ Line | Count | Source | 708 | 62 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 62 | execute_utf8<str_const, len_const, pad_const>( | 710 | 62 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 62 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 62 | }, |
_ZZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb0EESH_IbLb1EESJ_EEDaSC_SD_SE_ Line | Count | Source | 708 | 67 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 67 | execute_utf8<str_const, len_const, pad_const>( | 710 | 67 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 67 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 67 | }, |
_ZZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb1EESH_IbLb0EESJ_EEDaSC_SD_SE_ Line | Count | Source | 708 | 62 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 62 | execute_utf8<str_const, len_const, pad_const>( | 710 | 62 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 62 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 62 | }, |
_ZZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb1EESH_IbLb0EESI_EEDaSC_SD_SE_ Line | Count | Source | 708 | 62 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 62 | execute_utf8<str_const, len_const, pad_const>( | 710 | 62 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 62 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 62 | }, |
_ZZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb1EESI_SH_IbLb0EEEEDaSC_SD_SE_ Line | Count | Source | 708 | 62 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 62 | execute_utf8<str_const, len_const, pad_const>( | 710 | 62 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 62 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 62 | }, |
Unexecuted instantiation: _ZZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlT_T0_T1_E_clISt17integral_constantIbLb1EESI_SI_EEDaSC_SD_SE_ |
713 | 1.37k | make_bool_variant(col_const[0]), make_bool_variant(col_const[1]), |
714 | 1.37k | make_bool_variant(col_const[2])); |
715 | | |
716 | 1.37k | block.get_by_position(result).column = |
717 | 1.37k | ColumnNullable::create(std::move(res), std::move(null_map)); |
718 | 1.37k | return Status::OK(); |
719 | 1.37k | } _ZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 679 | 848 | uint32_t result, size_t input_rows_count) const override { | 680 | 848 | DCHECK_GE(arguments.size(), 3); | 681 | 848 | auto null_map = ColumnUInt8::create(input_rows_count, 0); | 682 | | // we create a zero column to simply implement | 683 | 848 | auto const_null_map = ColumnUInt8::create(input_rows_count, 0); | 684 | 848 | auto res = ColumnString::create(); | 685 | | | 686 | 848 | ColumnPtr col[3]; | 687 | 848 | bool col_const[3]; | 688 | 3.39k | for (size_t i = 0; i < 3; ++i) { | 689 | 2.54k | std::tie(col[i], col_const[i]) = | 690 | 2.54k | unpack_if_const(block.get_by_position(arguments[i]).column); | 691 | 2.54k | } | 692 | 848 | auto& null_map_data = null_map->get_data(); | 693 | 848 | auto& res_offsets = res->get_offsets(); | 694 | 848 | auto& res_chars = res->get_chars(); | 695 | 848 | res_offsets.resize(input_rows_count); | 696 | | | 697 | 848 | const auto* strcol = assert_cast<const ColumnString*>(col[0].get()); | 698 | 848 | const auto& strcol_offsets = strcol->get_offsets(); | 699 | 848 | const auto& strcol_chars = strcol->get_chars(); | 700 | | | 701 | 848 | const auto* col_len = assert_cast<const ColumnInt32*>(col[1].get()); | 702 | 848 | const auto& col_len_data = col_len->get_data(); | 703 | | | 704 | 848 | const auto* padcol = assert_cast<const ColumnString*>(col[2].get()); | 705 | 848 | const auto& padcol_offsets = padcol->get_offsets(); | 706 | 848 | const auto& padcol_chars = padcol->get_chars(); | 707 | 848 | std::visit( | 708 | 848 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 848 | execute_utf8<str_const, len_const, pad_const>( | 710 | 848 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 848 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 848 | }, | 713 | 848 | make_bool_variant(col_const[0]), make_bool_variant(col_const[1]), | 714 | 848 | make_bool_variant(col_const[2])); | 715 | | | 716 | 848 | block.get_by_position(result).column = | 717 | 848 | ColumnNullable::create(std::move(res), std::move(null_map)); | 718 | 848 | return Status::OK(); | 719 | 848 | } |
_ZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 679 | 528 | uint32_t result, size_t input_rows_count) const override { | 680 | 528 | DCHECK_GE(arguments.size(), 3); | 681 | 528 | auto null_map = ColumnUInt8::create(input_rows_count, 0); | 682 | | // we create a zero column to simply implement | 683 | 528 | auto const_null_map = ColumnUInt8::create(input_rows_count, 0); | 684 | 528 | auto res = ColumnString::create(); | 685 | | | 686 | 528 | ColumnPtr col[3]; | 687 | 528 | bool col_const[3]; | 688 | 2.11k | for (size_t i = 0; i < 3; ++i) { | 689 | 1.58k | std::tie(col[i], col_const[i]) = | 690 | 1.58k | unpack_if_const(block.get_by_position(arguments[i]).column); | 691 | 1.58k | } | 692 | 528 | auto& null_map_data = null_map->get_data(); | 693 | 528 | auto& res_offsets = res->get_offsets(); | 694 | 528 | auto& res_chars = res->get_chars(); | 695 | 528 | res_offsets.resize(input_rows_count); | 696 | | | 697 | 528 | const auto* strcol = assert_cast<const ColumnString*>(col[0].get()); | 698 | 528 | const auto& strcol_offsets = strcol->get_offsets(); | 699 | 528 | const auto& strcol_chars = strcol->get_chars(); | 700 | | | 701 | 528 | const auto* col_len = assert_cast<const ColumnInt32*>(col[1].get()); | 702 | 528 | const auto& col_len_data = col_len->get_data(); | 703 | | | 704 | 528 | const auto* padcol = assert_cast<const ColumnString*>(col[2].get()); | 705 | 528 | const auto& padcol_offsets = padcol->get_offsets(); | 706 | 528 | const auto& padcol_chars = padcol->get_chars(); | 707 | 528 | std::visit( | 708 | 528 | [&](auto str_const, auto len_const, auto pad_const) { | 709 | 528 | execute_utf8<str_const, len_const, pad_const>( | 710 | 528 | strcol_offsets, strcol_chars, col_len_data, padcol_offsets, | 711 | 528 | padcol_chars, res_offsets, res_chars, null_map_data, input_rows_count); | 712 | 528 | }, | 713 | 528 | make_bool_variant(col_const[0]), make_bool_variant(col_const[1]), | 714 | 528 | make_bool_variant(col_const[2])); | 715 | | | 716 | 528 | block.get_by_position(result).column = | 717 | 528 | ColumnNullable::create(std::move(res), std::move(null_map)); | 718 | 528 | return Status::OK(); | 719 | 528 | } |
|
720 | | |
721 | | template <bool str_const, bool len_const, bool pad_const> |
722 | | void execute_utf8(const ColumnString::Offsets& strcol_offsets, |
723 | | const ColumnString::Chars& strcol_chars, |
724 | | const ColumnInt32::Container& col_len_data, |
725 | | const ColumnString::Offsets& padcol_offsets, |
726 | | const ColumnString::Chars& padcol_chars, ColumnString::Offsets& res_offsets, |
727 | | ColumnString::Chars& res_chars, ColumnUInt8::Container& null_map_data, |
728 | 1.37k | size_t input_rows_count) const { |
729 | 1.37k | std::vector<size_t> pad_index; |
730 | 1.37k | size_t const_pad_char_size = 0; |
731 | | // If pad_const = true, initialize pad_index only once. |
732 | | // The same logic applies to the if constexpr (!pad_const) condition below. |
733 | 1.37k | if constexpr (pad_const) { |
734 | 388 | const_pad_char_size = simd::VStringFunctions::get_char_len( |
735 | 388 | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); |
736 | 388 | } |
737 | | |
738 | 1.37k | fmt::memory_buffer buffer; |
739 | 1.37k | buffer.resize(strcol_chars.size()); |
740 | 1.37k | size_t buffer_len = 0; |
741 | | |
742 | 5.11k | for (size_t i = 0; i < input_rows_count; ++i) { |
743 | 3.74k | if constexpr (!pad_const) { |
744 | 1.24k | pad_index.clear(); |
745 | 1.24k | } |
746 | 3.74k | const auto len = col_len_data[index_check_const<len_const>(i)]; |
747 | 3.74k | if (len < 0) { |
748 | | // return NULL when input length is invalid number |
749 | 562 | null_map_data[i] = true; |
750 | 562 | res_offsets[i] = buffer_len; |
751 | 3.17k | } else { |
752 | 3.17k | const auto str_idx = index_check_const<str_const>(i); |
753 | 3.17k | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; |
754 | 3.17k | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; |
755 | 3.17k | const auto pad_idx = index_check_const<pad_const>(i); |
756 | 3.17k | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; |
757 | 3.17k | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; |
758 | | |
759 | 3.17k | auto [iterate_byte_len, iterate_char_len] = |
760 | 3.17k | simd::VStringFunctions::iterate_utf8_with_limit_length( |
761 | 3.17k | (const char*)str_data, (const char*)str_data + str_len, len); |
762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len |
763 | 3.17k | if (iterate_char_len == len) { |
764 | 641 | buffer.resize(buffer_len + iterate_byte_len); |
765 | 641 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); |
766 | 641 | buffer_len += iterate_byte_len; |
767 | 641 | res_offsets[i] = buffer_len; |
768 | 641 | continue; |
769 | 641 | } |
770 | 2.53k | size_t pad_char_size; |
771 | 2.53k | if constexpr (!pad_const) { |
772 | 452 | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, |
773 | 452 | pad_len, pad_index); |
774 | 2.08k | } else { |
775 | 2.08k | pad_char_size = const_pad_char_size; |
776 | 2.08k | } |
777 | | |
778 | | // make compatible with mysql. return empty string if pad is empty |
779 | 2.53k | if (pad_char_size == 0) { |
780 | 18 | res_offsets[i] = buffer_len; |
781 | 18 | continue; |
782 | 18 | } |
783 | 2.52k | const size_t str_char_size = iterate_char_len; |
784 | 2.52k | const size_t pad_times = (len - str_char_size) / pad_char_size; |
785 | 2.52k | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; |
786 | 2.52k | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; |
787 | 2.52k | ColumnString::check_chars_length(buffer_len + new_capacity, i); |
788 | 2.52k | buffer.resize(buffer_len + new_capacity); |
789 | 2.52k | if constexpr (!Impl::is_lpad) { |
790 | 2.12k | memcpy(buffer.data() + buffer_len, str_data, str_len); |
791 | 2.12k | buffer_len += str_len; |
792 | 2.12k | } |
793 | | // Prepend chars of pad. |
794 | 2.52k | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, |
795 | 2.52k | pad_times); |
796 | 2.52k | buffer_len += pad_times * pad_len; |
797 | | |
798 | 2.52k | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); |
799 | 2.52k | buffer_len += pad_remainder_len; |
800 | | |
801 | 2.52k | if constexpr (Impl::is_lpad) { |
802 | 394 | memcpy(buffer.data() + buffer_len, str_data, str_len); |
803 | 394 | buffer_len += str_len; |
804 | 394 | } |
805 | 2.52k | res_offsets[i] = buffer_len; |
806 | 2.52k | } |
807 | 3.74k | } |
808 | 1.37k | res_chars.insert(buffer.data(), buffer.data() + buffer_len); |
809 | 1.37k | } _ZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_utf8ILb0ELb0ELb0EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 465 | size_t input_rows_count) const { | 729 | 465 | std::vector<size_t> pad_index; | 730 | 465 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | | if constexpr (pad_const) { | 734 | | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | | } | 737 | | | 738 | 465 | fmt::memory_buffer buffer; | 739 | 465 | buffer.resize(strcol_chars.size()); | 740 | 465 | size_t buffer_len = 0; | 741 | | | 742 | 1.06k | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | 596 | if constexpr (!pad_const) { | 744 | 596 | pad_index.clear(); | 745 | 596 | } | 746 | 596 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 596 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 89 | null_map_data[i] = true; | 750 | 89 | res_offsets[i] = buffer_len; | 751 | 507 | } else { | 752 | 507 | const auto str_idx = index_check_const<str_const>(i); | 753 | 507 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 507 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 507 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 507 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 507 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 507 | auto [iterate_byte_len, iterate_char_len] = | 760 | 507 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 507 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 507 | if (iterate_char_len == len) { | 764 | 135 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 135 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 135 | buffer_len += iterate_byte_len; | 767 | 135 | res_offsets[i] = buffer_len; | 768 | 135 | continue; | 769 | 135 | } | 770 | 372 | size_t pad_char_size; | 771 | 372 | if constexpr (!pad_const) { | 772 | 372 | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | 372 | pad_len, pad_index); | 774 | | } else { | 775 | | pad_char_size = const_pad_char_size; | 776 | | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 372 | if (pad_char_size == 0) { | 780 | 8 | res_offsets[i] = buffer_len; | 781 | 8 | continue; | 782 | 8 | } | 783 | 364 | const size_t str_char_size = iterate_char_len; | 784 | 364 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 364 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 364 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 364 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 364 | buffer.resize(buffer_len + new_capacity); | 789 | | if constexpr (!Impl::is_lpad) { | 790 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | | buffer_len += str_len; | 792 | | } | 793 | | // Prepend chars of pad. | 794 | 364 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 364 | pad_times); | 796 | 364 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 364 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 364 | buffer_len += pad_remainder_len; | 800 | | | 801 | 364 | if constexpr (Impl::is_lpad) { | 802 | 364 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | 364 | buffer_len += str_len; | 804 | 364 | } | 805 | 364 | res_offsets[i] = buffer_len; | 806 | 364 | } | 807 | 596 | } | 808 | 465 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 465 | } |
_ZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_utf8ILb0ELb0ELb1EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 62 | size_t input_rows_count) const { | 729 | 62 | std::vector<size_t> pad_index; | 730 | 62 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | 62 | if constexpr (pad_const) { | 734 | 62 | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | 62 | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | 62 | } | 737 | | | 738 | 62 | fmt::memory_buffer buffer; | 739 | 62 | buffer.resize(strcol_chars.size()); | 740 | 62 | size_t buffer_len = 0; | 741 | | | 742 | 124 | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | | if constexpr (!pad_const) { | 744 | | pad_index.clear(); | 745 | | } | 746 | 62 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 62 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 32 | null_map_data[i] = true; | 750 | 32 | res_offsets[i] = buffer_len; | 751 | 32 | } else { | 752 | 30 | const auto str_idx = index_check_const<str_const>(i); | 753 | 30 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 30 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 30 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 30 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 30 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 30 | auto [iterate_byte_len, iterate_char_len] = | 760 | 30 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 30 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 30 | if (iterate_char_len == len) { | 764 | 28 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 28 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 28 | buffer_len += iterate_byte_len; | 767 | 28 | res_offsets[i] = buffer_len; | 768 | 28 | continue; | 769 | 28 | } | 770 | 2 | size_t pad_char_size; | 771 | | if constexpr (!pad_const) { | 772 | | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | | pad_len, pad_index); | 774 | 2 | } else { | 775 | 2 | pad_char_size = const_pad_char_size; | 776 | 2 | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 2 | if (pad_char_size == 0) { | 780 | 0 | res_offsets[i] = buffer_len; | 781 | 0 | continue; | 782 | 0 | } | 783 | 2 | const size_t str_char_size = iterate_char_len; | 784 | 2 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 2 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 2 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 2 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 2 | buffer.resize(buffer_len + new_capacity); | 789 | | if constexpr (!Impl::is_lpad) { | 790 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | | buffer_len += str_len; | 792 | | } | 793 | | // Prepend chars of pad. | 794 | 2 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 2 | pad_times); | 796 | 2 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 2 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 2 | buffer_len += pad_remainder_len; | 800 | | | 801 | 2 | if constexpr (Impl::is_lpad) { | 802 | 2 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | 2 | buffer_len += str_len; | 804 | 2 | } | 805 | 2 | res_offsets[i] = buffer_len; | 806 | 2 | } | 807 | 62 | } | 808 | 62 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 62 | } |
_ZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_utf8ILb0ELb1ELb0EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 62 | size_t input_rows_count) const { | 729 | 62 | std::vector<size_t> pad_index; | 730 | 62 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | | if constexpr (pad_const) { | 734 | | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | | } | 737 | | | 738 | 62 | fmt::memory_buffer buffer; | 739 | 62 | buffer.resize(strcol_chars.size()); | 740 | 62 | size_t buffer_len = 0; | 741 | | | 742 | 124 | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | 62 | if constexpr (!pad_const) { | 744 | 62 | pad_index.clear(); | 745 | 62 | } | 746 | 62 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 62 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 32 | null_map_data[i] = true; | 750 | 32 | res_offsets[i] = buffer_len; | 751 | 32 | } else { | 752 | 30 | const auto str_idx = index_check_const<str_const>(i); | 753 | 30 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 30 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 30 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 30 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 30 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 30 | auto [iterate_byte_len, iterate_char_len] = | 760 | 30 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 30 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 30 | if (iterate_char_len == len) { | 764 | 28 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 28 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 28 | buffer_len += iterate_byte_len; | 767 | 28 | res_offsets[i] = buffer_len; | 768 | 28 | continue; | 769 | 28 | } | 770 | 2 | size_t pad_char_size; | 771 | 2 | if constexpr (!pad_const) { | 772 | 2 | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | 2 | pad_len, pad_index); | 774 | | } else { | 775 | | pad_char_size = const_pad_char_size; | 776 | | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 2 | if (pad_char_size == 0) { | 780 | 0 | res_offsets[i] = buffer_len; | 781 | 0 | continue; | 782 | 0 | } | 783 | 2 | const size_t str_char_size = iterate_char_len; | 784 | 2 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 2 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 2 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 2 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 2 | buffer.resize(buffer_len + new_capacity); | 789 | | if constexpr (!Impl::is_lpad) { | 790 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | | buffer_len += str_len; | 792 | | } | 793 | | // Prepend chars of pad. | 794 | 2 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 2 | pad_times); | 796 | 2 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 2 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 2 | buffer_len += pad_remainder_len; | 800 | | | 801 | 2 | if constexpr (Impl::is_lpad) { | 802 | 2 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | 2 | buffer_len += str_len; | 804 | 2 | } | 805 | 2 | res_offsets[i] = buffer_len; | 806 | 2 | } | 807 | 62 | } | 808 | 62 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 62 | } |
_ZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_utf8ILb0ELb1ELb1EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 73 | size_t input_rows_count) const { | 729 | 73 | std::vector<size_t> pad_index; | 730 | 73 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | 73 | if constexpr (pad_const) { | 734 | 73 | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | 73 | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | 73 | } | 737 | | | 738 | 73 | fmt::memory_buffer buffer; | 739 | 73 | buffer.resize(strcol_chars.size()); | 740 | 73 | size_t buffer_len = 0; | 741 | | | 742 | 176 | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | | if constexpr (!pad_const) { | 744 | | pad_index.clear(); | 745 | | } | 746 | 103 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 103 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 32 | null_map_data[i] = true; | 750 | 32 | res_offsets[i] = buffer_len; | 751 | 71 | } else { | 752 | 71 | const auto str_idx = index_check_const<str_const>(i); | 753 | 71 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 71 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 71 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 71 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 71 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 71 | auto [iterate_byte_len, iterate_char_len] = | 760 | 71 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 71 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 71 | if (iterate_char_len == len) { | 764 | 51 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 51 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 51 | buffer_len += iterate_byte_len; | 767 | 51 | res_offsets[i] = buffer_len; | 768 | 51 | continue; | 769 | 51 | } | 770 | 20 | size_t pad_char_size; | 771 | | if constexpr (!pad_const) { | 772 | | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | | pad_len, pad_index); | 774 | 20 | } else { | 775 | 20 | pad_char_size = const_pad_char_size; | 776 | 20 | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 20 | if (pad_char_size == 0) { | 780 | 0 | res_offsets[i] = buffer_len; | 781 | 0 | continue; | 782 | 0 | } | 783 | 20 | const size_t str_char_size = iterate_char_len; | 784 | 20 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 20 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 20 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 20 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 20 | buffer.resize(buffer_len + new_capacity); | 789 | | if constexpr (!Impl::is_lpad) { | 790 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | | buffer_len += str_len; | 792 | | } | 793 | | // Prepend chars of pad. | 794 | 20 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 20 | pad_times); | 796 | 20 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 20 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 20 | buffer_len += pad_remainder_len; | 800 | | | 801 | 20 | if constexpr (Impl::is_lpad) { | 802 | 20 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | 20 | buffer_len += str_len; | 804 | 20 | } | 805 | 20 | res_offsets[i] = buffer_len; | 806 | 20 | } | 807 | 103 | } | 808 | 73 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 73 | } |
_ZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_utf8ILb1ELb0ELb0EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 62 | size_t input_rows_count) const { | 729 | 62 | std::vector<size_t> pad_index; | 730 | 62 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | | if constexpr (pad_const) { | 734 | | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | | } | 737 | | | 738 | 62 | fmt::memory_buffer buffer; | 739 | 62 | buffer.resize(strcol_chars.size()); | 740 | 62 | size_t buffer_len = 0; | 741 | | | 742 | 124 | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | 62 | if constexpr (!pad_const) { | 744 | 62 | pad_index.clear(); | 745 | 62 | } | 746 | 62 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 62 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 32 | null_map_data[i] = true; | 750 | 32 | res_offsets[i] = buffer_len; | 751 | 32 | } else { | 752 | 30 | const auto str_idx = index_check_const<str_const>(i); | 753 | 30 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 30 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 30 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 30 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 30 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 30 | auto [iterate_byte_len, iterate_char_len] = | 760 | 30 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 30 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 30 | if (iterate_char_len == len) { | 764 | 28 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 28 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 28 | buffer_len += iterate_byte_len; | 767 | 28 | res_offsets[i] = buffer_len; | 768 | 28 | continue; | 769 | 28 | } | 770 | 2 | size_t pad_char_size; | 771 | 2 | if constexpr (!pad_const) { | 772 | 2 | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | 2 | pad_len, pad_index); | 774 | | } else { | 775 | | pad_char_size = const_pad_char_size; | 776 | | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 2 | if (pad_char_size == 0) { | 780 | 0 | res_offsets[i] = buffer_len; | 781 | 0 | continue; | 782 | 0 | } | 783 | 2 | const size_t str_char_size = iterate_char_len; | 784 | 2 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 2 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 2 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 2 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 2 | buffer.resize(buffer_len + new_capacity); | 789 | | if constexpr (!Impl::is_lpad) { | 790 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | | buffer_len += str_len; | 792 | | } | 793 | | // Prepend chars of pad. | 794 | 2 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 2 | pad_times); | 796 | 2 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 2 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 2 | buffer_len += pad_remainder_len; | 800 | | | 801 | 2 | if constexpr (Impl::is_lpad) { | 802 | 2 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | 2 | buffer_len += str_len; | 804 | 2 | } | 805 | 2 | res_offsets[i] = buffer_len; | 806 | 2 | } | 807 | 62 | } | 808 | 62 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 62 | } |
_ZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_utf8ILb1ELb0ELb1EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 62 | size_t input_rows_count) const { | 729 | 62 | std::vector<size_t> pad_index; | 730 | 62 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | 62 | if constexpr (pad_const) { | 734 | 62 | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | 62 | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | 62 | } | 737 | | | 738 | 62 | fmt::memory_buffer buffer; | 739 | 62 | buffer.resize(strcol_chars.size()); | 740 | 62 | size_t buffer_len = 0; | 741 | | | 742 | 124 | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | | if constexpr (!pad_const) { | 744 | | pad_index.clear(); | 745 | | } | 746 | 62 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 62 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 32 | null_map_data[i] = true; | 750 | 32 | res_offsets[i] = buffer_len; | 751 | 32 | } else { | 752 | 30 | const auto str_idx = index_check_const<str_const>(i); | 753 | 30 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 30 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 30 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 30 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 30 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 30 | auto [iterate_byte_len, iterate_char_len] = | 760 | 30 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 30 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 30 | if (iterate_char_len == len) { | 764 | 28 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 28 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 28 | buffer_len += iterate_byte_len; | 767 | 28 | res_offsets[i] = buffer_len; | 768 | 28 | continue; | 769 | 28 | } | 770 | 2 | size_t pad_char_size; | 771 | | if constexpr (!pad_const) { | 772 | | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | | pad_len, pad_index); | 774 | 2 | } else { | 775 | 2 | pad_char_size = const_pad_char_size; | 776 | 2 | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 2 | if (pad_char_size == 0) { | 780 | 0 | res_offsets[i] = buffer_len; | 781 | 0 | continue; | 782 | 0 | } | 783 | 2 | const size_t str_char_size = iterate_char_len; | 784 | 2 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 2 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 2 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 2 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 2 | buffer.resize(buffer_len + new_capacity); | 789 | | if constexpr (!Impl::is_lpad) { | 790 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | | buffer_len += str_len; | 792 | | } | 793 | | // Prepend chars of pad. | 794 | 2 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 2 | pad_times); | 796 | 2 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 2 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 2 | buffer_len += pad_remainder_len; | 800 | | | 801 | 2 | if constexpr (Impl::is_lpad) { | 802 | 2 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | 2 | buffer_len += str_len; | 804 | 2 | } | 805 | 2 | res_offsets[i] = buffer_len; | 806 | 2 | } | 807 | 62 | } | 808 | 62 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 62 | } |
_ZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_utf8ILb1ELb1ELb0EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 62 | size_t input_rows_count) const { | 729 | 62 | std::vector<size_t> pad_index; | 730 | 62 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | | if constexpr (pad_const) { | 734 | | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | | } | 737 | | | 738 | 62 | fmt::memory_buffer buffer; | 739 | 62 | buffer.resize(strcol_chars.size()); | 740 | 62 | size_t buffer_len = 0; | 741 | | | 742 | 124 | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | 62 | if constexpr (!pad_const) { | 744 | 62 | pad_index.clear(); | 745 | 62 | } | 746 | 62 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 62 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 32 | null_map_data[i] = true; | 750 | 32 | res_offsets[i] = buffer_len; | 751 | 32 | } else { | 752 | 30 | const auto str_idx = index_check_const<str_const>(i); | 753 | 30 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 30 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 30 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 30 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 30 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 30 | auto [iterate_byte_len, iterate_char_len] = | 760 | 30 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 30 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 30 | if (iterate_char_len == len) { | 764 | 28 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 28 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 28 | buffer_len += iterate_byte_len; | 767 | 28 | res_offsets[i] = buffer_len; | 768 | 28 | continue; | 769 | 28 | } | 770 | 2 | size_t pad_char_size; | 771 | 2 | if constexpr (!pad_const) { | 772 | 2 | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | 2 | pad_len, pad_index); | 774 | | } else { | 775 | | pad_char_size = const_pad_char_size; | 776 | | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 2 | if (pad_char_size == 0) { | 780 | 0 | res_offsets[i] = buffer_len; | 781 | 0 | continue; | 782 | 0 | } | 783 | 2 | const size_t str_char_size = iterate_char_len; | 784 | 2 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 2 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 2 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 2 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 2 | buffer.resize(buffer_len + new_capacity); | 789 | | if constexpr (!Impl::is_lpad) { | 790 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | | buffer_len += str_len; | 792 | | } | 793 | | // Prepend chars of pad. | 794 | 2 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 2 | pad_times); | 796 | 2 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 2 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 2 | buffer_len += pad_remainder_len; | 800 | | | 801 | 2 | if constexpr (Impl::is_lpad) { | 802 | 2 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | 2 | buffer_len += str_len; | 804 | 2 | } | 805 | 2 | res_offsets[i] = buffer_len; | 806 | 2 | } | 807 | 62 | } | 808 | 62 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 62 | } |
Unexecuted instantiation: _ZNK5doris17FunctionStringPadINS_10StringLPadEE12execute_utf8ILb1ELb1ELb1EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m _ZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_utf8ILb0ELb0ELb0EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 151 | size_t input_rows_count) const { | 729 | 151 | std::vector<size_t> pad_index; | 730 | 151 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | | if constexpr (pad_const) { | 734 | | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | | } | 737 | | | 738 | 151 | fmt::memory_buffer buffer; | 739 | 151 | buffer.resize(strcol_chars.size()); | 740 | 151 | size_t buffer_len = 0; | 741 | | | 742 | 432 | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | 281 | if constexpr (!pad_const) { | 744 | 281 | pad_index.clear(); | 745 | 281 | } | 746 | 281 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 281 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 89 | null_map_data[i] = true; | 750 | 89 | res_offsets[i] = buffer_len; | 751 | 192 | } else { | 752 | 192 | const auto str_idx = index_check_const<str_const>(i); | 753 | 192 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 192 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 192 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 192 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 192 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 192 | auto [iterate_byte_len, iterate_char_len] = | 760 | 192 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 192 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 192 | if (iterate_char_len == len) { | 764 | 124 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 124 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 124 | buffer_len += iterate_byte_len; | 767 | 124 | res_offsets[i] = buffer_len; | 768 | 124 | continue; | 769 | 124 | } | 770 | 68 | size_t pad_char_size; | 771 | 68 | if constexpr (!pad_const) { | 772 | 68 | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | 68 | pad_len, pad_index); | 774 | | } else { | 775 | | pad_char_size = const_pad_char_size; | 776 | | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 68 | if (pad_char_size == 0) { | 780 | 10 | res_offsets[i] = buffer_len; | 781 | 10 | continue; | 782 | 10 | } | 783 | 58 | const size_t str_char_size = iterate_char_len; | 784 | 58 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 58 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 58 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 58 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 58 | buffer.resize(buffer_len + new_capacity); | 789 | 58 | if constexpr (!Impl::is_lpad) { | 790 | 58 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | 58 | buffer_len += str_len; | 792 | 58 | } | 793 | | // Prepend chars of pad. | 794 | 58 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 58 | pad_times); | 796 | 58 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 58 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 58 | buffer_len += pad_remainder_len; | 800 | | | 801 | | if constexpr (Impl::is_lpad) { | 802 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | | buffer_len += str_len; | 804 | | } | 805 | 58 | res_offsets[i] = buffer_len; | 806 | 58 | } | 807 | 281 | } | 808 | 151 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 151 | } |
_ZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_utf8ILb0ELb0ELb1EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 62 | size_t input_rows_count) const { | 729 | 62 | std::vector<size_t> pad_index; | 730 | 62 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | 62 | if constexpr (pad_const) { | 734 | 62 | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | 62 | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | 62 | } | 737 | | | 738 | 62 | fmt::memory_buffer buffer; | 739 | 62 | buffer.resize(strcol_chars.size()); | 740 | 62 | size_t buffer_len = 0; | 741 | | | 742 | 124 | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | | if constexpr (!pad_const) { | 744 | | pad_index.clear(); | 745 | | } | 746 | 62 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 62 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 32 | null_map_data[i] = true; | 750 | 32 | res_offsets[i] = buffer_len; | 751 | 32 | } else { | 752 | 30 | const auto str_idx = index_check_const<str_const>(i); | 753 | 30 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 30 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 30 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 30 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 30 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 30 | auto [iterate_byte_len, iterate_char_len] = | 760 | 30 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 30 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 30 | if (iterate_char_len == len) { | 764 | 28 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 28 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 28 | buffer_len += iterate_byte_len; | 767 | 28 | res_offsets[i] = buffer_len; | 768 | 28 | continue; | 769 | 28 | } | 770 | 2 | size_t pad_char_size; | 771 | | if constexpr (!pad_const) { | 772 | | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | | pad_len, pad_index); | 774 | 2 | } else { | 775 | 2 | pad_char_size = const_pad_char_size; | 776 | 2 | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 2 | if (pad_char_size == 0) { | 780 | 0 | res_offsets[i] = buffer_len; | 781 | 0 | continue; | 782 | 0 | } | 783 | 2 | const size_t str_char_size = iterate_char_len; | 784 | 2 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 2 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 2 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 2 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 2 | buffer.resize(buffer_len + new_capacity); | 789 | 2 | if constexpr (!Impl::is_lpad) { | 790 | 2 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | 2 | buffer_len += str_len; | 792 | 2 | } | 793 | | // Prepend chars of pad. | 794 | 2 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 2 | pad_times); | 796 | 2 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 2 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 2 | buffer_len += pad_remainder_len; | 800 | | | 801 | | if constexpr (Impl::is_lpad) { | 802 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | | buffer_len += str_len; | 804 | | } | 805 | 2 | res_offsets[i] = buffer_len; | 806 | 2 | } | 807 | 62 | } | 808 | 62 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 62 | } |
_ZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_utf8ILb0ELb1ELb0EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 62 | size_t input_rows_count) const { | 729 | 62 | std::vector<size_t> pad_index; | 730 | 62 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | | if constexpr (pad_const) { | 734 | | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | | } | 737 | | | 738 | 62 | fmt::memory_buffer buffer; | 739 | 62 | buffer.resize(strcol_chars.size()); | 740 | 62 | size_t buffer_len = 0; | 741 | | | 742 | 124 | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | 62 | if constexpr (!pad_const) { | 744 | 62 | pad_index.clear(); | 745 | 62 | } | 746 | 62 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 62 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 32 | null_map_data[i] = true; | 750 | 32 | res_offsets[i] = buffer_len; | 751 | 32 | } else { | 752 | 30 | const auto str_idx = index_check_const<str_const>(i); | 753 | 30 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 30 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 30 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 30 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 30 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 30 | auto [iterate_byte_len, iterate_char_len] = | 760 | 30 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 30 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 30 | if (iterate_char_len == len) { | 764 | 28 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 28 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 28 | buffer_len += iterate_byte_len; | 767 | 28 | res_offsets[i] = buffer_len; | 768 | 28 | continue; | 769 | 28 | } | 770 | 2 | size_t pad_char_size; | 771 | 2 | if constexpr (!pad_const) { | 772 | 2 | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | 2 | pad_len, pad_index); | 774 | | } else { | 775 | | pad_char_size = const_pad_char_size; | 776 | | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 2 | if (pad_char_size == 0) { | 780 | 0 | res_offsets[i] = buffer_len; | 781 | 0 | continue; | 782 | 0 | } | 783 | 2 | const size_t str_char_size = iterate_char_len; | 784 | 2 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 2 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 2 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 2 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 2 | buffer.resize(buffer_len + new_capacity); | 789 | 2 | if constexpr (!Impl::is_lpad) { | 790 | 2 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | 2 | buffer_len += str_len; | 792 | 2 | } | 793 | | // Prepend chars of pad. | 794 | 2 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 2 | pad_times); | 796 | 2 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 2 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 2 | buffer_len += pad_remainder_len; | 800 | | | 801 | | if constexpr (Impl::is_lpad) { | 802 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | | buffer_len += str_len; | 804 | | } | 805 | 2 | res_offsets[i] = buffer_len; | 806 | 2 | } | 807 | 62 | } | 808 | 62 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 62 | } |
_ZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_utf8ILb0ELb1ELb1EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 67 | size_t input_rows_count) const { | 729 | 67 | std::vector<size_t> pad_index; | 730 | 67 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | 67 | if constexpr (pad_const) { | 734 | 67 | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | 67 | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | 67 | } | 737 | | | 738 | 67 | fmt::memory_buffer buffer; | 739 | 67 | buffer.resize(strcol_chars.size()); | 740 | 67 | size_t buffer_len = 0; | 741 | | | 742 | 2.20k | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | | if constexpr (!pad_const) { | 744 | | pad_index.clear(); | 745 | | } | 746 | 2.14k | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 2.14k | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 32 | null_map_data[i] = true; | 750 | 32 | res_offsets[i] = buffer_len; | 751 | 2.10k | } else { | 752 | 2.10k | const auto str_idx = index_check_const<str_const>(i); | 753 | 2.10k | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 2.10k | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 2.10k | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 2.10k | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 2.10k | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 2.10k | auto [iterate_byte_len, iterate_char_len] = | 760 | 2.10k | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 2.10k | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 2.10k | if (iterate_char_len == len) { | 764 | 51 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 51 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 51 | buffer_len += iterate_byte_len; | 767 | 51 | res_offsets[i] = buffer_len; | 768 | 51 | continue; | 769 | 51 | } | 770 | 2.05k | size_t pad_char_size; | 771 | | if constexpr (!pad_const) { | 772 | | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | | pad_len, pad_index); | 774 | 2.05k | } else { | 775 | 2.05k | pad_char_size = const_pad_char_size; | 776 | 2.05k | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 2.05k | if (pad_char_size == 0) { | 780 | 0 | res_offsets[i] = buffer_len; | 781 | 0 | continue; | 782 | 0 | } | 783 | 2.05k | const size_t str_char_size = iterate_char_len; | 784 | 2.05k | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 2.05k | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 2.05k | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 2.05k | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 2.05k | buffer.resize(buffer_len + new_capacity); | 789 | 2.05k | if constexpr (!Impl::is_lpad) { | 790 | 2.05k | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | 2.05k | buffer_len += str_len; | 792 | 2.05k | } | 793 | | // Prepend chars of pad. | 794 | 2.05k | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 2.05k | pad_times); | 796 | 2.05k | buffer_len += pad_times * pad_len; | 797 | | | 798 | 2.05k | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 2.05k | buffer_len += pad_remainder_len; | 800 | | | 801 | | if constexpr (Impl::is_lpad) { | 802 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | | buffer_len += str_len; | 804 | | } | 805 | 2.05k | res_offsets[i] = buffer_len; | 806 | 2.05k | } | 807 | 2.14k | } | 808 | 67 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 67 | } |
_ZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_utf8ILb1ELb0ELb0EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 62 | size_t input_rows_count) const { | 729 | 62 | std::vector<size_t> pad_index; | 730 | 62 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | | if constexpr (pad_const) { | 734 | | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | | } | 737 | | | 738 | 62 | fmt::memory_buffer buffer; | 739 | 62 | buffer.resize(strcol_chars.size()); | 740 | 62 | size_t buffer_len = 0; | 741 | | | 742 | 124 | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | 62 | if constexpr (!pad_const) { | 744 | 62 | pad_index.clear(); | 745 | 62 | } | 746 | 62 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 62 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 32 | null_map_data[i] = true; | 750 | 32 | res_offsets[i] = buffer_len; | 751 | 32 | } else { | 752 | 30 | const auto str_idx = index_check_const<str_const>(i); | 753 | 30 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 30 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 30 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 30 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 30 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 30 | auto [iterate_byte_len, iterate_char_len] = | 760 | 30 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 30 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 30 | if (iterate_char_len == len) { | 764 | 28 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 28 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 28 | buffer_len += iterate_byte_len; | 767 | 28 | res_offsets[i] = buffer_len; | 768 | 28 | continue; | 769 | 28 | } | 770 | 2 | size_t pad_char_size; | 771 | 2 | if constexpr (!pad_const) { | 772 | 2 | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | 2 | pad_len, pad_index); | 774 | | } else { | 775 | | pad_char_size = const_pad_char_size; | 776 | | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 2 | if (pad_char_size == 0) { | 780 | 0 | res_offsets[i] = buffer_len; | 781 | 0 | continue; | 782 | 0 | } | 783 | 2 | const size_t str_char_size = iterate_char_len; | 784 | 2 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 2 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 2 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 2 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 2 | buffer.resize(buffer_len + new_capacity); | 789 | 2 | if constexpr (!Impl::is_lpad) { | 790 | 2 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | 2 | buffer_len += str_len; | 792 | 2 | } | 793 | | // Prepend chars of pad. | 794 | 2 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 2 | pad_times); | 796 | 2 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 2 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 2 | buffer_len += pad_remainder_len; | 800 | | | 801 | | if constexpr (Impl::is_lpad) { | 802 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | | buffer_len += str_len; | 804 | | } | 805 | 2 | res_offsets[i] = buffer_len; | 806 | 2 | } | 807 | 62 | } | 808 | 62 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 62 | } |
_ZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_utf8ILb1ELb0ELb1EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 62 | size_t input_rows_count) const { | 729 | 62 | std::vector<size_t> pad_index; | 730 | 62 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | 62 | if constexpr (pad_const) { | 734 | 62 | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | 62 | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | 62 | } | 737 | | | 738 | 62 | fmt::memory_buffer buffer; | 739 | 62 | buffer.resize(strcol_chars.size()); | 740 | 62 | size_t buffer_len = 0; | 741 | | | 742 | 124 | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | | if constexpr (!pad_const) { | 744 | | pad_index.clear(); | 745 | | } | 746 | 62 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 62 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 32 | null_map_data[i] = true; | 750 | 32 | res_offsets[i] = buffer_len; | 751 | 32 | } else { | 752 | 30 | const auto str_idx = index_check_const<str_const>(i); | 753 | 30 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 30 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 30 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 30 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 30 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 30 | auto [iterate_byte_len, iterate_char_len] = | 760 | 30 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 30 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 30 | if (iterate_char_len == len) { | 764 | 28 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 28 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 28 | buffer_len += iterate_byte_len; | 767 | 28 | res_offsets[i] = buffer_len; | 768 | 28 | continue; | 769 | 28 | } | 770 | 2 | size_t pad_char_size; | 771 | | if constexpr (!pad_const) { | 772 | | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | | pad_len, pad_index); | 774 | 2 | } else { | 775 | 2 | pad_char_size = const_pad_char_size; | 776 | 2 | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 2 | if (pad_char_size == 0) { | 780 | 0 | res_offsets[i] = buffer_len; | 781 | 0 | continue; | 782 | 0 | } | 783 | 2 | const size_t str_char_size = iterate_char_len; | 784 | 2 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 2 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 2 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 2 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 2 | buffer.resize(buffer_len + new_capacity); | 789 | 2 | if constexpr (!Impl::is_lpad) { | 790 | 2 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | 2 | buffer_len += str_len; | 792 | 2 | } | 793 | | // Prepend chars of pad. | 794 | 2 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 2 | pad_times); | 796 | 2 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 2 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 2 | buffer_len += pad_remainder_len; | 800 | | | 801 | | if constexpr (Impl::is_lpad) { | 802 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | | buffer_len += str_len; | 804 | | } | 805 | 2 | res_offsets[i] = buffer_len; | 806 | 2 | } | 807 | 62 | } | 808 | 62 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 62 | } |
_ZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_utf8ILb1ELb1ELb0EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m Line | Count | Source | 728 | 62 | size_t input_rows_count) const { | 729 | 62 | std::vector<size_t> pad_index; | 730 | 62 | size_t const_pad_char_size = 0; | 731 | | // If pad_const = true, initialize pad_index only once. | 732 | | // The same logic applies to the if constexpr (!pad_const) condition below. | 733 | | if constexpr (pad_const) { | 734 | | const_pad_char_size = simd::VStringFunctions::get_char_len( | 735 | | (const char*)padcol_chars.data(), padcol_offsets[0], pad_index); | 736 | | } | 737 | | | 738 | 62 | fmt::memory_buffer buffer; | 739 | 62 | buffer.resize(strcol_chars.size()); | 740 | 62 | size_t buffer_len = 0; | 741 | | | 742 | 124 | for (size_t i = 0; i < input_rows_count; ++i) { | 743 | 62 | if constexpr (!pad_const) { | 744 | 62 | pad_index.clear(); | 745 | 62 | } | 746 | 62 | const auto len = col_len_data[index_check_const<len_const>(i)]; | 747 | 62 | if (len < 0) { | 748 | | // return NULL when input length is invalid number | 749 | 32 | null_map_data[i] = true; | 750 | 32 | res_offsets[i] = buffer_len; | 751 | 32 | } else { | 752 | 30 | const auto str_idx = index_check_const<str_const>(i); | 753 | 30 | const int str_len = strcol_offsets[str_idx] - strcol_offsets[str_idx - 1]; | 754 | 30 | const auto* str_data = &strcol_chars[strcol_offsets[str_idx - 1]]; | 755 | 30 | const auto pad_idx = index_check_const<pad_const>(i); | 756 | 30 | const int pad_len = padcol_offsets[pad_idx] - padcol_offsets[pad_idx - 1]; | 757 | 30 | const auto* pad_data = &padcol_chars[padcol_offsets[pad_idx - 1]]; | 758 | | | 759 | 30 | auto [iterate_byte_len, iterate_char_len] = | 760 | 30 | simd::VStringFunctions::iterate_utf8_with_limit_length( | 761 | 30 | (const char*)str_data, (const char*)str_data + str_len, len); | 762 | | // If iterate_char_len equals len, it indicates that the str length is greater than or equal to len | 763 | 30 | if (iterate_char_len == len) { | 764 | 28 | buffer.resize(buffer_len + iterate_byte_len); | 765 | 28 | memcpy(buffer.data() + buffer_len, str_data, iterate_byte_len); | 766 | 28 | buffer_len += iterate_byte_len; | 767 | 28 | res_offsets[i] = buffer_len; | 768 | 28 | continue; | 769 | 28 | } | 770 | 2 | size_t pad_char_size; | 771 | 2 | if constexpr (!pad_const) { | 772 | 2 | pad_char_size = simd::VStringFunctions::get_char_len((const char*)pad_data, | 773 | 2 | pad_len, pad_index); | 774 | | } else { | 775 | | pad_char_size = const_pad_char_size; | 776 | | } | 777 | | | 778 | | // make compatible with mysql. return empty string if pad is empty | 779 | 2 | if (pad_char_size == 0) { | 780 | 0 | res_offsets[i] = buffer_len; | 781 | 0 | continue; | 782 | 0 | } | 783 | 2 | const size_t str_char_size = iterate_char_len; | 784 | 2 | const size_t pad_times = (len - str_char_size) / pad_char_size; | 785 | 2 | const size_t pad_remainder_len = pad_index[(len - str_char_size) % pad_char_size]; | 786 | 2 | const size_t new_capacity = str_len + size_t(pad_times + 1) * pad_len; | 787 | 2 | ColumnString::check_chars_length(buffer_len + new_capacity, i); | 788 | 2 | buffer.resize(buffer_len + new_capacity); | 789 | 2 | if constexpr (!Impl::is_lpad) { | 790 | 2 | memcpy(buffer.data() + buffer_len, str_data, str_len); | 791 | 2 | buffer_len += str_len; | 792 | 2 | } | 793 | | // Prepend chars of pad. | 794 | 2 | StringOP::fast_repeat((uint8_t*)buffer.data() + buffer_len, pad_data, pad_len, | 795 | 2 | pad_times); | 796 | 2 | buffer_len += pad_times * pad_len; | 797 | | | 798 | 2 | memcpy(buffer.data() + buffer_len, pad_data, pad_remainder_len); | 799 | 2 | buffer_len += pad_remainder_len; | 800 | | | 801 | | if constexpr (Impl::is_lpad) { | 802 | | memcpy(buffer.data() + buffer_len, str_data, str_len); | 803 | | buffer_len += str_len; | 804 | | } | 805 | 2 | res_offsets[i] = buffer_len; | 806 | 2 | } | 807 | 62 | } | 808 | 62 | res_chars.insert(buffer.data(), buffer.data() + buffer_len); | 809 | 62 | } |
Unexecuted instantiation: _ZNK5doris17FunctionStringPadINS_10StringRPadEE12execute_utf8ILb1ELb1ELb1EEEvRKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERKNS4_IhLm4096ES7_Lm16ELm15EEERKNS4_IiLm4096ES7_Lm16ELm15EEESA_SD_RS8_RSB_SI_m |
810 | | }; |
811 | | |
812 | | #include "common/compile_check_avoid_end.h" |
813 | | } // namespace doris |