HappenLee commented on code in PR #12807: URL: https://github.com/apache/doris/pull/12807#discussion_r979950567
########## be/src/vec/columns/column_vector.cpp: ########## @@ -349,20 +349,22 @@ void ColumnVector<T>::insert_range_from(const IColumn& src, size_t start, size_t template <typename T> void ColumnVector<T>::insert_indices_from(const IColumn& src, const int* indices_begin, const int* indices_end) { - const Self& src_vec = assert_cast<const Self&>(src); auto origin_size = size(); auto new_size = indices_end - indices_begin; data.resize(origin_size + new_size); - for (int i = 0; i < new_size; ++i) { - int offset = indices_begin[i]; - if constexpr (std::is_same_v<T, UInt8>) { - // Now Uint8 use to identify null and non null - // 1. nullable column : offset == -1 means is null at the here, set true here - // 2. real data column : offset == -1 what at is meaningless - data[origin_size + i] = (offset == -1) ? T {1} : src_vec.get_element(offset); - } else { - data[origin_size + i] = (offset == -1) ? T {0} : src_vec.get_element(offset); + const T* src_data = reinterpret_cast<const T*>(src.get_raw_data().data); + + if constexpr (std::is_same_v<T, UInt8>) { + // nullmap : indices_begin[i] == -1 means is null at the here, set true here + for (int i = 0; i < new_size; ++i) { + data[origin_size + i] = (indices_begin[i] == -1) + + (indices_begin[i] != -1) * src_data[indices_begin[i]]; + } + } else { + // real data : indices_begin[i] == -1 what at is meaningless + for (int i = 0; i < new_size; ++i) { + data[origin_size + i] = src_data[indices_begin[i]]; Review Comment: This is undefined behavior, and might break horribly -- 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