@@ -23,14 +23,12 @@ use std::mem::{size_of, size_of_val};
23
23
use std:: sync:: Arc ;
24
24
25
25
use arrow:: array:: {
26
- make_array, new_empty_array, Array , ArrayRef , AsArray , BooleanArray , ListArray ,
27
- StructArray ,
26
+ new_empty_array, Array , ArrayRef , AsArray , BooleanArray , ListArray , StructArray ,
28
27
} ;
29
28
use arrow:: compute:: { filter, SortOptions } ;
30
29
use arrow:: datatypes:: { DataType , Field , FieldRef , Fields } ;
31
30
32
31
use datafusion_common:: cast:: as_list_array;
33
- use datafusion_common:: scalar:: copy_array_data;
34
32
use datafusion_common:: utils:: { get_row_at_idx, SingleRowListArrayBuilder } ;
35
33
use datafusion_common:: { exec_err, internal_err, Result , ScalarValue } ;
36
34
use datafusion_expr:: function:: { AccumulatorArgs , StateFieldsArgs } ;
@@ -315,11 +313,7 @@ impl Accumulator for ArrayAggAccumulator {
315
313
} ;
316
314
317
315
if !val. is_empty ( ) {
318
- // The ArrayRef might be holding a reference to its original input buffer, so
319
- // storing it here directly copied/compacted avoids over accounting memory
320
- // not used here.
321
- self . values
322
- . push ( make_array ( copy_array_data ( & val. to_data ( ) ) ) ) ;
316
+ self . values . push ( val)
323
317
}
324
318
325
319
Ok ( ( ) )
@@ -378,7 +372,7 @@ impl Accumulator for ArrayAggAccumulator {
378
372
+ self
379
373
. values
380
374
. iter ( )
381
- . map ( |arr| arr. get_array_memory_size ( ) )
375
+ . map ( |arr| arr. to_data ( ) . get_slice_memory_size ( ) . unwrap_or_default ( ) )
382
376
. sum :: < usize > ( )
383
377
+ self . datatype . size ( )
384
378
- size_of_val ( & self . datatype )
@@ -1008,8 +1002,7 @@ mod tests {
1008
1002
acc2. update_batch ( & [ data ( [ "b" , "c" , "a" ] ) ] ) ?;
1009
1003
acc1 = merge ( acc1, acc2) ?;
1010
1004
1011
- // without compaction, the size is 2652.
1012
- assert_eq ! ( acc1. size( ) , 732 ) ;
1005
+ assert_eq ! ( acc1. size( ) , 266 ) ;
1013
1006
1014
1007
Ok ( ( ) )
1015
1008
}
0 commit comments