HappenLee commented on code in PR #52994:
URL: https://github.com/apache/doris/pull/52994#discussion_r2203741577
##########
be/src/vec/columns/column_nullable.cpp:
##########
@@ -211,68 +211,61 @@ void ColumnNullable::insert_many_from(const IColumn& src,
size_t position, size_
StringRef ColumnNullable::serialize_value_into_arena(size_t n, Arena& arena,
char const*& begin) const
{
- const auto& arr = get_null_map_data();
- static constexpr auto s = sizeof(arr[0]);
-
- auto* pos = arena.alloc_continue(s, begin);
- memcpy(pos, &arr[n], s);
-
- if (arr[n]) {
- return {pos, s};
- }
-
- auto nested_ref = get_nested_column().serialize_value_into_arena(n, arena,
begin);
-
- /// serialize_value_into_arena may reallocate memory. Have to use ptr from
nested_ref.data and move it back.
- return {nested_ref.data - s, nested_ref.size + s};
+ auto* pos = arena.alloc_continue(serialize_size_at(n), begin);
+ return {pos, serialize_impl(pos, n)};
}
const char* ColumnNullable::deserialize_and_insert_from_arena(const char* pos)
{
+ return pos + deserialize_impl(pos);
+}
+
+size_t ColumnNullable::deserialize_impl(const char* pos) {
+ size_t sz = 0;
UInt8 val = *reinterpret_cast<const UInt8*>(pos);
- pos += sizeof(val);
+ sz += sizeof(val);
get_null_map_data().push_back(val);
if (val == 0) {
- pos = get_nested_column().deserialize_and_insert_from_arena(pos);
+ sz += get_nested_column().deserialize_impl(pos + sz);
} else {
get_nested_column().insert_default();
_has_null = true;
_need_update_has_null = false;
}
-
- return pos;
+ return sz;
}
size_t ColumnNullable::get_max_row_byte_size() const {
constexpr auto flag_size = sizeof(NullMap::value_type);
return flag_size + get_nested_column().get_max_row_byte_size();
}
-void ColumnNullable::serialize_vec(StringRef* keys, size_t num_rows,
- size_t max_row_byte_size) const {
+size_t ColumnNullable::serialize_impl(char* pos, const size_t row) const {
const auto& arr = get_null_map_data();
- get_nested_column().serialize_vec_with_null_map(keys, num_rows,
arr.data());
+ memcpy_fixed<NullMap::value_type>(pos, (char*)&arr[row]);
+ if (arr[row]) {
+ return sizeof(NullMap::value_type);
+ }
+ return sizeof(NullMap::value_type) +
+ get_nested_column().serialize_impl(pos +
sizeof(NullMap::value_type), row);
+}
+
+void ColumnNullable::serialize_vec(StringRef* keys, size_t num_rows) const {
Review Comment:
!_has_null
// process not null serialize
get_nested_column().deserialize_vec(keys, num_rows);
for loop num_rows
--
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]