kosiew commented on code in PR #27895:
URL: https://github.com/apache/datafusion/pull/27895#discussion_r4765430617


##########
datafusion/common/src/heap_size.rs:
##########
@@ -719,16 +720,38 @@ mod tests {
             Some(vec![Some(1), Some(2), Some(3)]),
             Some(vec![Some(4)]),
         ]);
-        assert_eq!(size(&array), array.get_array_memory_size());
-        assert!(size(&array) > 0);
+        assert_eq!(
+            size(&array),

Review Comment:
   Could we add direct regression coverage for ListViewArray and 
LargeListViewArray to verify that both exclude their outer array object's 
inline size?



##########
datafusion/execution/src/cache/default_cache.rs:
##########
@@ -1225,6 +1225,50 @@ mod tests {
         assert_eq!(cache.memory_used(), 0);
     }
 
+    #[test]
+    fn test_cache_admits_struct_statistic_at_exact_limit() {
+        let array = StructArray::from(vec![(
+            Arc::new(Field::new("x", DataType::Int32, false)),
+            Arc::new(Int32Array::from(vec![42])) as _,
+        )]);
+        let schema = Schema::new(vec![Field::new("s", 
array.data_type().clone(), false)]);
+        let mut stats = Statistics::new_unknown(&schema);
+        let meta = create_test_meta("test.parquet", 100);
+        let key = TableScopedPath {
+            path: meta.location.clone(),
+            table: None,
+        };
+
+        let arc_refcounts = 2 * size_of::<usize>();
+        let struct_bytes = arc_refcounts + array.get_array_memory_size();
+        let stats_overhead = arc_refcounts
+            + size_of::<Statistics>()
+            + stats.column_statistics.capacity() * 
size_of::<ColumnStatistics>();
+        let budget = key.path.as_ref().len()
+            + meta.location.as_ref().len()
+            + stats_overhead
+            + struct_bytes;
+
+        stats.column_statistics[0].min_value =
+            Precision::Exact(ScalarValue::Struct(Arc::new(array)));

Review Comment:
   Could we add a separate exact-fit admission test using an independently 
calculated budget from Arrow's struct estimate, Arc refcounts, and the 
remaining entry size? Both sides of this assertion use the same estimator, so 
duplicate accounting could go undetected.



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