Mryange commented on code in PR #66031:
URL: https://github.com/apache/doris/pull/66031#discussion_r3682719555
##########
be/src/core/block/column_with_type_and_name.cpp:
##########
@@ -105,41 +105,49 @@ void
ColumnWithTypeAndName::to_pb_column_meta(PColumnMeta* col_meta) const {
type->to_pb_column_meta(col_meta);
}
-ColumnWithTypeAndName ColumnWithTypeAndName::unnest_nullable(
- bool replace_null_data_to_default) const {
- if (type->is_nullable()) {
- auto nested_type =
- assert_cast<const DataTypeNullable*,
TypeCheckOnRelease::DISABLE>(type.get())
- ->get_nested_type();
- ColumnPtr nested_column = column;
- if (column) {
- // A column_ptr is needed here to ensure that the column in
convert_to_full_column_if_const is not released.
- auto [column_ptr, is_const] = unpack_if_const(column);
- const auto* source_column =
- assert_cast<const ColumnNullable*,
TypeCheckOnRelease::DISABLE>(
- column_ptr.get());
- if (is_const) {
- nested_column =
-
ColumnConst::create(source_column->get_nested_column_ptr(), column->size());
- } else {
- nested_column = source_column->get_nested_column_ptr();
- }
-
- if (replace_null_data_to_default) {
- const auto& null_map = source_column->get_null_map_data();
- // only need to mutate nested column, avoid to copy nullmap
- auto mutable_nested_col = (*std::move(nested_column)).mutate();
- if (simd::contain_one(null_map.data(), null_map.size())) {
-
mutable_nested_col->replace_column_null_data(null_map.data());
- }
-
- return {std::move(mutable_nested_col), nested_type, ""};
- }
- }
- return {nested_column, nested_type, ""};
+NullableColumnInfo ColumnWithTypeAndName::get_nullable_column_info() const {
+ DCHECK(type->is_nullable());
+ DCHECK(column);
+
+ // A column_ptr is needed here to ensure that the column in
convert_to_full_column_if_const is
+ // not released.
+ auto [column_ptr, is_const] = unpack_if_const(column);
+ const auto* source_column =
+ assert_cast<const ColumnNullable*,
TypeCheckOnRelease::DISABLE>(column_ptr.get());
+ const auto& null_map = source_column->get_null_map_data();
+ const size_t non_null_count =
+ simd::count_zero_num(reinterpret_cast<const
int8_t*>(null_map.data()), null_map.size());
+
+ ColumnPtr nested_column;
+ if (is_const) {
+ nested_column =
ColumnConst::create(source_column->get_nested_column_ptr(), column->size());
} else {
+ nested_column = source_column->get_nested_column_ptr();
+ }
+
+ return {.nested_column = std::move(nested_column),
+ .null_map_column = source_column->get_null_map_column_ptr(),
+ .non_null_count = non_null_count,
+ .is_const = is_const,
+ .is_nullable = true};
+}
+
+ColumnWithTypeAndName ColumnWithTypeAndName::unnest_nullable(
+ const NullableColumnInfo& info, bool replace_null_data_to_default)
const {
+ if (!type->is_nullable()) {
return {column, type, ""};
}
+ DCHECK(info.is_nullable);
+
+ auto nested_type = assert_cast<const DataTypeNullable*,
TypeCheckOnRelease::DISABLE>(type.get())
+ ->get_nested_type();
+ if (replace_null_data_to_default && info.has_null()) {
Review Comment:
> 这个得想办法in place修改,每次拷贝的代价有点高啊。NULL 位置的 payload
确实是死数据,改了不影响查询结果,这个是个关键路径,我觉得值得想办法优化一下
这个过去就是有一个copy,cow的要求。 如果一个函数对于性能要求比较高,比如算术运算这种,他就不应该走默认的null处理。
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]