mohitgurav20 commented on code in PR #27196:
URL: https://github.com/apache/datafusion/pull/27196#discussion_r4752682838


##########
datafusion/physical-plan/src/aggregates/order/partial.rs:
##########
@@ -87,15 +88,10 @@ enum State {
 }
 
 impl State {
-    fn heap_size(&self) -> usize {
+    fn heap_size(&self, ctx: &mut DFHeapSizeCtx) -> usize {
         match self {
-            State::Taken => 0,
-            State::Start => 0,
-            State::InProgress { group_key, .. } => group_key
-                .iter()
-                .map(|scalar_value| scalar_value.size())
-                .sum(),
-            State::Complete => 0,
+            State::InProgress { group_key, .. } => group_key.heap_size(ctx),

Review Comment:
   also to clarify heap_size_no_double_count_for_struct_key: it builds a 
ScalarValue::Struct directly and checks partial.heap_size() against 
grouping_indices capacity, group_key slot capacity, and 
arr.get_array_memory_size(), confirming it avoids the extra Arc<StructArray> 
header overcount (2 * size_of::<usize>() + size_of::<StructArray>()) that 
DFHeapSize currently triggers (tracked in #27885).



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