linrrzqqq commented on code in PR #70774:
URL: https://github.com/apache/doris/pull/70774#discussion_r4661699063
##########
be/src/core/data_type/data_type_bitmap.cpp:
##########
@@ -61,17 +61,12 @@ char* DataTypeBitMap::serialize(const IColumn& column,
char* buf, int be_exec_ve
const auto& data_column = assert_cast<const ColumnBitmap&>(*bitmap_column);
// serialize the bitmap size array
auto* meta_ptr = reinterpret_cast<size_t*>(buf);
- for (size_t i = 0; i < real_need_copy_num; ++i) {
- auto& bitmap = data_column.get_element(i);
- unaligned_store<size_t>(&meta_ptr[i], bitmap.getSizeInBytes());
- }
-
- // serialize each bitmap
char* data_ptr = buf + sizeof(size_t) * real_need_copy_num;
for (size_t i = 0; i < real_need_copy_num; ++i) {
auto& bitmap = data_column.get_element(i);
- bitmap.write_to(data_ptr);
- data_ptr += unaligned_load<size_t>(&meta_ptr[i]);
+ const auto size = bitmap.write_optimized_to(data_ptr);
Review Comment:
Doris 中 `get_uncompressed_serialized_bytes()`
本身就是upper-bound,而非精确字节数:`Block::serialize()`(已有 `HLL`
相关注释)、`AggregateFunctionArrayAgg`、`AggregateFunctionTopK` 以及
`AggregateFunctionMapAggV2`(value 列)都是按其返回值预分配缓冲区,再以 `serialize()` 实际写入的字节数为准。
`97fda04` 已经修复了此前假设精确长度的 `SingleValueDataColumn::write()`,并将相关单测断言对齐为
`ASSERT_LE`。如果为了精确预估而在 `get_uncompressed_serialized_bytes()`
中不修改原对象地计算优化后大小,每个未优化 bitmap 都需要克隆并执行两次 `runOptimize()`(算大小一次、序列化一次),会带来不必要的
CPU 和内存开销。
--
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]