Skip to content

Commit 5a0eecb

Browse files
committed
add used()
1 parent a5b960c commit 5a0eecb

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

datafusion/physical-plan/src/aggregates/no_grouping.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::metrics::{BaselineMetrics, RecordOutput};
2525
use crate::{RecordBatchStream, SendableRecordBatchStream};
2626
use arrow::datatypes::SchemaRef;
2727
use arrow::record_batch::RecordBatch;
28-
use arrow_buffer::TrackingMemoryPool;
28+
use arrow_buffer::{MemoryPool, TrackingMemoryPool};
2929
use datafusion_common::{Result, ScalarValue, internal_datafusion_err, internal_err};
3030
use datafusion_execution::TaskContext;
3131
use datafusion_expr::Operator;
@@ -437,6 +437,7 @@ fn aggregate_batch(
437437
arrow_pool: &TrackingMemoryPool,
438438
) -> Result<usize> {
439439
let mut allocated = 0usize;
440+
let pool_size_pre = arrow_pool.used();
440441

441442
// 1.1 iterate accumulators and respective expressions together
442443
// 1.2 filter the batch if necessary
@@ -473,5 +474,8 @@ fn aggregate_batch(
473474
res
474475
})?;
475476

477+
let pool_size_post = arrow_pool.used();
478+
allocated += pool_size_post.saturating_sub(pool_size_pre);
479+
476480
Ok(allocated)
477481
}

datafusion/physical-plan/src/aggregates/row_hash.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use crate::{RecordBatchStream, SendableRecordBatchStream};
3838

3939
use arrow::array::*;
4040
use arrow::datatypes::SchemaRef;
41-
use arrow_buffer::TrackingMemoryPool;
41+
use arrow_buffer::{MemoryPool, TrackingMemoryPool};
4242
use datafusion_common::{
4343
DataFusionError, Result, assert_eq_or_internal_err, assert_or_internal_err,
4444
internal_err,
@@ -1069,7 +1069,8 @@ impl GroupedHashAggregateStream {
10691069
.accumulators
10701070
.iter()
10711071
.map(|x| x.size(Some(&self.arrow_pool)))
1072-
.sum::<usize>();
1072+
.sum::<usize>()
1073+
+ self.arrow_pool.used();
10731074

10741075
let reservation_result = self.reservation.try_resize(total_size);
10751076

0 commit comments

Comments
 (0)