tustvold commented on code in PR #4280:
URL: https://github.com/apache/arrow-rs/pull/4280#discussion_r1208029159


##########
parquet/src/column/writer/mod.rs:
##########
@@ -441,6 +452,16 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E> 
{
         self.column_metrics.total_bytes_written
     }
 
+    /// Returns the estimated total bytes for this column writer
+    ///
+    /// Unlike [`Self::get_total_bytes_written`] this includes an estimate
+    /// of any data that has not yet been flushed to a pge
+    pub(crate) fn get_estimated_total_bytes(&self) -> u64 {
+        self.column_metrics.total_bytes_written
+            + self.encoder.estimated_data_page_size() as u64

Review Comment:
   As the encoders all buffer encoded data internally, this is a fairly 
accurate estimation of the memory usage. 
   
   Edit: it will still be an underestimate as the allocations may be larger 
than needed, but this is fairly accurate, and doesn't require any new APIs



##########
parquet/src/column/writer/mod.rs:
##########
@@ -441,6 +452,16 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E> 
{
         self.column_metrics.total_bytes_written
     }
 
+    /// Returns the estimated total bytes for this column writer
+    ///
+    /// Unlike [`Self::get_total_bytes_written`] this includes an estimate
+    /// of any data that has not yet been flushed to a pge
+    pub(crate) fn get_estimated_total_bytes(&self) -> u64 {
+        self.column_metrics.total_bytes_written
+            + self.encoder.estimated_data_page_size() as u64

Review Comment:
   As the encoders all buffer encoded data internally, this is a fairly 
accurate estimation of the memory usage. 
   
   Edit: it will still be an underestimate as the allocations may be larger 
than needed, but this is fairly accurate, and doesn't require any breaking 
changes



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

Reply via email to