[Improvement](join) remove insert_indices_from_join and special judge for -1 (#27779)
remove insert_indices_from_join and special judge for -1
This commit is contained in:
@ -124,10 +124,10 @@ void ColumnString::insert_range_from(const IColumn& src, size_t start, size_t le
|
||||
}
|
||||
}
|
||||
|
||||
void ColumnString::insert_indices_from(const IColumn& src, const int* indices_begin,
|
||||
const int* indices_end) {
|
||||
const ColumnString& src_str = assert_cast<const ColumnString&>(src);
|
||||
auto src_offset_data = src_str.offsets.data();
|
||||
void ColumnString::insert_indices_from(const IColumn& src, const uint32_t* indices_begin,
|
||||
const uint32_t* indices_end) {
|
||||
const auto& src_str = assert_cast<const ColumnString&>(src);
|
||||
const auto* src_offset_data = src_str.offsets.data();
|
||||
|
||||
auto old_char_size = chars.size();
|
||||
size_t total_chars_size = old_char_size;
|
||||
@ -136,65 +136,24 @@ void ColumnString::insert_indices_from(const IColumn& src, const int* indices_be
|
||||
offsets.resize(offsets.size() + indices_end - indices_begin);
|
||||
auto* dst_offsets_data = offsets.data();
|
||||
|
||||
for (auto x = indices_begin; x != indices_end; ++x) {
|
||||
if (*x != -1) {
|
||||
total_chars_size += src_offset_data[*x] - src_offset_data[*x - 1];
|
||||
}
|
||||
for (const auto* x = indices_begin; x != indices_end; ++x) {
|
||||
total_chars_size += src_offset_data[*x] - src_offset_data[int(*x) - 1];
|
||||
dst_offsets_data[dst_offsets_pos++] = total_chars_size;
|
||||
}
|
||||
check_chars_length(total_chars_size, offsets.size());
|
||||
|
||||
chars.resize(total_chars_size);
|
||||
|
||||
auto* src_data_ptr = src_str.chars.data();
|
||||
const auto* src_data_ptr = src_str.chars.data();
|
||||
auto* dst_data_ptr = chars.data();
|
||||
|
||||
size_t dst_chars_pos = old_char_size;
|
||||
for (auto x = indices_begin; x != indices_end; ++x) {
|
||||
if (*x != -1) {
|
||||
const size_t size_to_append = src_offset_data[*x] - src_offset_data[*x - 1];
|
||||
const size_t offset = src_offset_data[*x - 1];
|
||||
memcpy_small_allow_read_write_overflow15(dst_data_ptr + dst_chars_pos,
|
||||
src_data_ptr + offset, size_to_append);
|
||||
dst_chars_pos += size_to_append;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ColumnString::insert_indices_from_join(const IColumn& src, const uint32_t* indices_begin,
|
||||
const uint32_t* indices_end) {
|
||||
const ColumnString& src_str = assert_cast<const ColumnString&>(src);
|
||||
auto src_offset_data = src_str.offsets.data();
|
||||
|
||||
auto old_char_size = chars.size();
|
||||
size_t total_chars_size = old_char_size;
|
||||
|
||||
auto dst_offsets_pos = offsets.size();
|
||||
offsets.resize(offsets.size() + indices_end - indices_begin);
|
||||
auto* dst_offsets_data = offsets.data();
|
||||
|
||||
for (auto x = indices_begin; x != indices_end; ++x) {
|
||||
if (*x != 0) {
|
||||
total_chars_size += src_offset_data[*x] - src_offset_data[*x - 1];
|
||||
}
|
||||
dst_offsets_data[dst_offsets_pos++] = total_chars_size;
|
||||
}
|
||||
check_chars_length(total_chars_size, offsets.size());
|
||||
|
||||
chars.resize(total_chars_size);
|
||||
|
||||
auto* src_data_ptr = src_str.chars.data();
|
||||
auto* dst_data_ptr = chars.data();
|
||||
|
||||
size_t dst_chars_pos = old_char_size;
|
||||
for (auto x = indices_begin; x != indices_end; ++x) {
|
||||
if (*x != 0) {
|
||||
const size_t size_to_append = src_offset_data[*x] - src_offset_data[*x - 1];
|
||||
const size_t offset = src_offset_data[*x - 1];
|
||||
memcpy_small_allow_read_write_overflow15(dst_data_ptr + dst_chars_pos,
|
||||
src_data_ptr + offset, size_to_append);
|
||||
dst_chars_pos += size_to_append;
|
||||
}
|
||||
for (const auto* x = indices_begin; x != indices_end; ++x) {
|
||||
const size_t size_to_append = src_offset_data[*x] - src_offset_data[int(*x) - 1];
|
||||
const size_t offset = src_offset_data[int(*x) - 1];
|
||||
memcpy_small_allow_read_write_overflow15(dst_data_ptr + dst_chars_pos,
|
||||
src_data_ptr + offset, size_to_append);
|
||||
dst_chars_pos += size_to_append;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user