zhannngchen commented on code in PR #51001:
URL: https://github.com/apache/doris/pull/51001#discussion_r2097831686


##########
be/src/olap/rowset/segment_v2/segment_writer.cpp:
##########
@@ -811,7 +813,18 @@ Status SegmentWriter::append_block(const 
vectorized::Block* block, size_t row_po
         }
         
RETURN_IF_ERROR(_column_writers[id]->append(converted_result.second->get_nullmap(),
                                                     
converted_result.second->get_data(), num_rows));
+
+        // estimate column data size for flush memtable, may be inaccurate at 
low cardinality
+        column_data_size += _column_writers[id]->estimate_buffer_size();
+        total_data_size += column_data_size;
+        auto origin_column_data_size = _footer.columns(id).total_data_size();
+        
_footer.mutable_columns(id)->set_total_data_size(origin_column_data_size +
+                                                         column_data_size);
     }
+
+    auto origin_data_footprint = _footer.data_footprint();
+    _footer.set_data_footprint(origin_data_footprint + total_data_size);

Review Comment:
   you don't need to accumulate these stats in each `append_block`, you can get 
the final stats once in the `finalize` method



-- 
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]

Reply via email to