LiaCastaneda commented on code in PR #19501:
URL: https://github.com/apache/datafusion/pull/19501#discussion_r2655404934
##########
datafusion/functions-aggregate/src/array_agg.rs:
##########
@@ -518,13 +518,29 @@ impl Accumulator for DistinctArrayAggAccumulator {
Ok(ScalarValue::List(arr))
}
- fn size(&self) -> usize {
- size_of_val(self) + ScalarValue::size_of_hashset(&self.values)
- - size_of_val(&self.values)
+ fn size(&self, pool: Option<&dyn MemoryPool>) -> usize {
+ let mut total = size_of_val(self)
+ + size_of_val(&self.values)
+ + (size_of::<ScalarValue>() * self.values.capacity())
+ self.datatype.size()
- size_of_val(&self.datatype)
- size_of_val(&self.sort_options)
- + size_of::<Option<SortOptions>>()
+ + size_of::<Option<SortOptions>>();
+
+ for scalar in &self.values {
+ if let Some(array) = scalar.get_array_ref() {
+ total += size_of::<Arc<dyn Array>>();
+ if let Some(pool) = pool {
+ claim_buffers_recursive(&array.to_data(), pool);
Review Comment:
So this is how we would use the pool properly
([link](https://github.com/LiaCastaneda/datafusion/blob/5a0eecbdf0b0a53c9645764d7be37ea8a2e26d4e/datafusion/physical-plan/src/aggregates/row_hash.rs#L1065))
to calculate the total size without counting shared buffers multiple times
--
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]