zhiqiang-hhhh commented on code in PR #28030: URL: https://github.com/apache/doris/pull/28030#discussion_r1418466479
########## be/src/vec/functions/function_string.h: ########## @@ -1911,6 +1927,58 @@ class FunctionSplitByString : public IFunction { } } + void _execute_constant_src_string(const StringRef& str_ref, const ColumnString& delimiter_col, + IColumn& dest_nested_column, + ColumnArray::Offsets64& dest_offsets, + NullMapType* dest_nested_null_map) const { + ColumnString& dest_column_string = reinterpret_cast<ColumnString&>(dest_nested_column); + ColumnString::Chars& column_string_chars = dest_column_string.get_chars(); + ColumnString::Offsets& column_string_offsets = dest_column_string.get_offsets(); + column_string_chars.reserve(0); + + ColumnArray::Offset64 string_pos = 0; + ColumnArray::Offset64 dest_pos = 0; + const ColumnArray::Offset64 delimiter_offsets_size = delimiter_col.get_offsets().size(); + + for (size_t i = 0; i < delimiter_offsets_size; ++i) { + const StringRef delimiter_ref = delimiter_col.get_data_at(i); + + if (delimiter_ref.size == 0) { + for (size_t str_pos = 0; str_pos < str_ref.size;) { + const size_t str_offset = str_pos; + const size_t old_size = column_string_chars.size(); + str_pos++; + const size_t new_size = old_size + 1; + column_string_chars.resize(new_size); + memcpy(column_string_chars.data() + old_size, str_ref.data + str_offset, 1); + (*dest_nested_null_map).push_back(false); + string_pos++; + dest_pos++; + column_string_offsets.push_back(string_pos); + } + } else { + for (size_t str_pos = 0; str_pos <= str_ref.size;) { + const size_t str_offset = str_pos; + const size_t old_size = column_string_chars.size(); + const size_t split_part_size = split_str(str_pos, str_ref, delimiter_ref); + str_pos += delimiter_ref.size; + const size_t new_size = old_size + split_part_size; + column_string_chars.resize(new_size); + if (split_part_size > 0) { Review Comment: I think we are safe here, since ColumnString uses PaddedPODArray as its data type. `using PaddedPODArray = PODArray<T, initial_bytes, TAllocator, 15, 16>;` means str_ref will always safe to reading/writing 16 bytes after its end. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org