mohitgurav20 opened a new pull request, #25825:
URL: https://github.com/apache/datafusion/pull/25825

   ## Which issue does this PR close?
   Closes #25734
   Related to #25188
   
   ## Rationale for this change
   `GroupValuesPrimitive::size()` was incorrectly estimating its hash-table 
allocation as `map.capacity() * size_of::<(usize, u64)>()`. This naive 
calculation omitted `hashbrown`'s control bytes and trailing group allocation. 
   
   As a result, the reported memory size was smaller than the actual retained 
allocation (which is especially problematic for small tables). This PR corrects 
the retained-capacity accounting by utilizing `self.map.allocation_size()` 
directly, just like `ArrowBytesMap::size()`.
   
   ## What changes are included in this PR?
   - Replaced the capacity approximation in `GroupValuesPrimitive::size()` with 
`self.map.allocation_size()`.
   - Added a focused test `test_exact_hash_table_allocation_accounting` to 
`primitive.rs`.
   - The tests rigorously compare the reported size delta against the 
independently observed `map.allocation_size()` across empty, grown, and 
retained-after-emit map capacity states.
   
   ## Are these changes tested?
   Yes, added the `test_exact_hash_table_allocation_accounting` unit test 
inside `primitive.rs`. 
   
   ## Are there any user-facing changes?
   No API changes. This strictly improves the internal memory-pool accounting 
for primitive single-column grouping.
   


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