mohitgurav20 commented on code in PR #27196:
URL: https://github.com/apache/datafusion/pull/27196#discussion_r4752648772
##########
datafusion/physical-plan/src/aggregates/order/partial.rs:
##########
@@ -89,13 +90,16 @@ enum State {
impl State {
fn heap_size(&self) -> 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::Taken | State::Start | State::Complete => 0,
+ State::InProgress { group_key, .. } => {
+ // Charge every slot (including spare capacity) and the extra
+ // heap each scalar owns. ScalarValue::size_of_vec already
+ // accounts for capacity * size_of::<ScalarValue>() plus the
+ // per-scalar payload, but it also adds size_of::<Vec<_>>()
+ // for the Vec descriptor; that descriptor is already counted
+ // by the containing enum variant, so subtract it here.
+ ScalarValue::size_of_vec(group_key) -
size_of::<Vec<ScalarValue>>()
+ }
Review Comment:
@kosiew i have added a TODO comment noting that State::heap_size can move
to DFHeapSize once #27885 is fixed.
--
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]