LiaCastaneda commented on code in PR #19501:
URL: https://github.com/apache/datafusion/pull/19501#discussion_r2655395063
##########
datafusion/functions-aggregate/src/first_last.rs:
##########
@@ -1524,11 +1576,36 @@ impl Accumulator for LastValueAccumulator {
Ok(self.last.clone())
}
- fn size(&self) -> usize {
- size_of_val(self) - size_of_val(&self.last)
- + self.last.size()
- + ScalarValue::size_of_vec(&self.orderings)
- - size_of_val(&self.orderings)
+ fn size(&self, pool: Option<&dyn MemoryPool>) -> usize {
+ let mut total =
+ size_of_val(self) - size_of_val(&self.last) -
size_of_val(&self.orderings)
+ + size_of::<ScalarValue>() * self.orderings.capacity();
+
+ if let Some(array) = self.last.get_array_ref() {
+ total += size_of::<Arc<dyn Array>>();
+ if let Some(pool) = pool {
+ claim_buffers_recursive(&array.to_data(), pool);
+ } else {
+ total += self.last.size() - size_of_val(&self.last);
+ }
+ } else {
+ total += self.last.size();
+ }
+
+ for scalar in &self.orderings {
+ 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);
+ } else {
+ total += scalar.size() - size_of_val(scalar);
+ }
+ } else {
+ total += scalar.size() - size_of_val(scalar);
+ }
Review Comment:
yep, good idea
--
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]