adonis0147 commented on a change in pull request #8494: URL: https://github.com/apache/incubator-doris/pull/8494#discussion_r827865851
########## File path: be/src/vec/core/block.cpp ########## @@ -701,63 +702,102 @@ doris::Tuple* Block::deep_copy_tuple(const doris::TupleDescriptor& desc, MemPool for (int i = 0; i < desc.slots().size(); ++i) { auto slot_desc = desc.slots()[i]; - auto data_ref = get_by_position(column_offset + i).column->get_data_at(row); - - if (data_ref.data == nullptr) { + auto column = get_by_position(column_offset + i).column; + Field field; + column->get(row, field); + if (field.is_null()) { dst->set_null(slot_desc->null_indicator_offset()); - continue; } else { dst->set_not_null(slot_desc->null_indicator_offset()); + deep_copy_slot(dst->get_slot(slot_desc->tuple_offset()), slot_desc->type(), pool, + column.get(), row, padding_char); } + } + return dst; +} - if (!slot_desc->type().is_string_type() && !slot_desc->type().is_date_type()) { - memcpy((void*)dst->get_slot(slot_desc->tuple_offset()), data_ref.data, data_ref.size); - } else if (slot_desc->type().is_string_type() && slot_desc->type() != TYPE_OBJECT && - slot_desc->type() != TYPE_HLL) { - memcpy((void*)dst->get_slot(slot_desc->tuple_offset()), (const void*)(&data_ref), - sizeof(data_ref)); - // Copy the content of string - if (padding_char && slot_desc->type() == TYPE_CHAR) { - // serialize the content of string - auto string_slot = dst->get_string_slot(slot_desc->tuple_offset()); - string_slot->ptr = reinterpret_cast<char*>(pool->allocate(slot_desc->type().len)); - string_slot->len = slot_desc->type().len; - memset(string_slot->ptr, 0, slot_desc->type().len); - memcpy(string_slot->ptr, data_ref.data, data_ref.size); - } else { - auto str_ptr = pool->allocate(data_ref.size); - memcpy(str_ptr, data_ref.data, data_ref.size); - dst->get_string_slot(slot_desc->tuple_offset())->ptr = - reinterpret_cast<char*>(str_ptr); - } - } else if (slot_desc->type() == TYPE_OBJECT) { - auto bitmap_value = (BitmapValue*)(data_ref.data); - auto size = bitmap_value->getSizeInBytes(); - +void Block::deep_copy_slot(void* dst, const doris::TypeDescriptor& type_desc, MemPool* pool, + const IColumn* column, int row, bool padding_char) { Review comment: I'm not clear about what you mean, but I also think the code here is not elegant. I tried my best to reuse the original logic of `Block::deep_copy_tuple`. As a result, the copy logic for item in array is reused. -- 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