Copilot commented on code in PR #20077:
URL: https://github.com/apache/datafusion/pull/20077#discussion_r2746905042


##########
datafusion/physical-expr-common/src/binary_view_map.rs:
##########
@@ -437,7 +437,7 @@ where
         let views_size = self.views.len() * size_of::<u128>();
         let in_progress_size = self.in_progress.capacity();
         let completed_size: usize = self.completed.iter().map(|b| 
b.len()).sum();
-        let nulls_size = self.nulls.len() / 8;
+        let nulls_size = self.nulls.allocated_size();

Review Comment:
   The `NullBufferBuilder::allocated_size()` method returns the capacity in 
bits, not bytes. This line should be `let nulls_size = 
self.nulls.allocated_size() / 8;` to convert bits to bytes.
   
   According to the comment in 
`datafusion/physical-plan/src/aggregates/group_values/null_builder.rs:66`, 
"NullBufferBuilder::allocated_size returns capacity in bits". Other places in 
the codebase that use `NullBufferBuilder` directly (such as 
`MaybeNullBufferBuilder::allocated_size()` at 
`datafusion/physical-plan/src/aggregates/group_values/null_builder.rs:67`) also 
divide by 8 to convert from bits to bytes.
   
   Without this division, the memory accounting would overcount by 8x.
   ```suggestion
           let nulls_size = self.nulls.allocated_size() / 8;
   ```



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