Boulea7 commented on code in PR #24229:
URL: https://github.com/apache/datafusion/pull/24229#discussion_r3755432568
##########
datafusion/physical-expr-common/src/binary_map.rs:
##########
@@ -264,6 +266,21 @@ where
new_self
}
+ fn insert_entry(
+ map: &mut hashbrown::hash_table::HashTable<Entry<O, V>>,
+ map_size: &mut usize,
+ entry: Entry<O, V>,
+ ) {
+ let capacity = map.capacity();
+ map.insert_accounted(entry, |entry| entry.hash, map_size);
+
+ // `insert_accounted` estimates growth from capacity. Keep `map_size`
+ // consistent with the exact allocation recorded by `new` after a
resize.
+ if map.capacity() != capacity {
Review Comment:
Thanks for catching that—the relationship is easy to miss in the diff. Both
`ArrowBytesMap::size()` and `ArrowBytesViewMap::size()` already add
`self.map_size`, and the set wrappers delegate to those methods, so
initializing and resynchronizing `map_size` changes the reported size without
another change to `size()`. I've replaced the test with public API coverage
that makes this behavior explicit.
##########
datafusion/physical-expr-common/src/binary_map.rs:
##########
@@ -874,6 +883,33 @@ mod tests {
assert!(size_after_values2 > total_strings1_len + total_strings2_len);
}
+ #[test]
+ fn test_size_includes_hash_table_allocation() {
+ fn allocated_size(map: &ArrowBytesMap<i32, ()>) -> usize {
Review Comment:
Good point. I've replaced the private-field assertions with integration
tests that use only the public `new`, `size`, `insert_if_new`, and `take` APIs.
They cover the initial hash-table allocation, growth, populated `take()`, and
reset behavior without depending on internal fields.
--
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]