[fix](expr) fix performance problem caused by too many virtual function call (#28508)
This commit is contained in:
@ -39,9 +39,9 @@
|
||||
|
||||
namespace doris::vectorized {
|
||||
|
||||
std::tuple<Block, ColumnNumbers> create_block_with_nested_columns(const Block& block,
|
||||
const ColumnNumbers& args,
|
||||
const bool need_check_same) {
|
||||
std::tuple<Block, ColumnNumbers> create_block_with_nested_columns(
|
||||
const Block& block, const ColumnNumbers& args, const bool need_check_same,
|
||||
bool need_replace_null_data_to_default) {
|
||||
Block res;
|
||||
ColumnNumbers res_args(args.size());
|
||||
res.reserve(args.size() + 1);
|
||||
@ -70,10 +70,22 @@ std::tuple<Block, ColumnNumbers> create_block_with_nested_columns(const Block& b
|
||||
|
||||
if (!col.column) {
|
||||
res.insert({nullptr, nested_type, col.name});
|
||||
} else if (auto* nullable = check_and_get_column<ColumnNullable>(*col.column)) {
|
||||
const auto& nested_col = nullable->get_nested_column_ptr();
|
||||
res.insert({nested_col, nested_type, col.name});
|
||||
} else if (auto* const_column = check_and_get_column<ColumnConst>(*col.column)) {
|
||||
} else if (const auto* nullable =
|
||||
check_and_get_column<ColumnNullable>(*col.column)) {
|
||||
if (need_replace_null_data_to_default) {
|
||||
const auto& null_map = nullable->get_null_map_data();
|
||||
const auto nested_col = nullable->get_nested_column_ptr();
|
||||
// only need to mutate nested column, avoid to copy nullmap
|
||||
auto mutable_nested_col = (*std::move(nested_col)).mutate();
|
||||
mutable_nested_col->replace_column_null_data(null_map.data());
|
||||
|
||||
res.insert({std::move(mutable_nested_col), nested_type, col.name});
|
||||
} else {
|
||||
const auto& nested_col = nullable->get_nested_column_ptr();
|
||||
res.insert({nested_col, nested_type, col.name});
|
||||
}
|
||||
} else if (const auto* const_column =
|
||||
check_and_get_column<ColumnConst>(*col.column)) {
|
||||
const auto& nested_col =
|
||||
check_and_get_column<ColumnNullable>(const_column->get_data_column())
|
||||
->get_nested_column_ptr();
|
||||
@ -104,10 +116,11 @@ std::tuple<Block, ColumnNumbers> create_block_with_nested_columns(const Block& b
|
||||
return {std::move(res), std::move(res_args)};
|
||||
}
|
||||
|
||||
std::tuple<Block, ColumnNumbers, size_t> create_block_with_nested_columns(const Block& block,
|
||||
const ColumnNumbers& args,
|
||||
size_t result) {
|
||||
auto [res, res_args] = create_block_with_nested_columns(block, args, true);
|
||||
std::tuple<Block, ColumnNumbers, size_t> create_block_with_nested_columns(
|
||||
const Block& block, const ColumnNumbers& args, size_t result,
|
||||
bool need_replace_null_data_to_default) {
|
||||
auto [res, res_args] =
|
||||
create_block_with_nested_columns(block, args, true, need_replace_null_data_to_default);
|
||||
// insert result column in temp block
|
||||
res.insert(block.get_by_position(result));
|
||||
return {std::move(res), std::move(res_args), res.columns() - 1};
|
||||
|
||||
Reference in New Issue
Block a user