File tree 1 file changed +4
-2
lines changed
datafusion/functions-aggregate/src
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -382,7 +382,7 @@ impl<T: ArrowNumericType + Send> GroupsAccumulator for MedianGroupsAccumulator<T
382
382
// Build offsets
383
383
let mut offsets = Vec :: with_capacity ( self . group_values . len ( ) + 1 ) ;
384
384
offsets. push ( 0 ) ;
385
- let mut cur_len = 0 ;
385
+ let mut cur_len = 0_i32 ;
386
386
for group_value in & emit_group_values {
387
387
cur_len += group_value. len ( ) as i32 ;
388
388
offsets. push ( cur_len) ;
@@ -443,8 +443,10 @@ impl<T: ArrowNumericType + Send> GroupsAccumulator for MedianGroupsAccumulator<T
443
443
. with_data_type ( self . data_type . clone ( ) ) ;
444
444
445
445
// `offsets` in `ListArray`, each row as a list element
446
+ assert ! ( input_array. len( ) <= i32 :: MAX as usize ) ;
446
447
let offsets = ( 0 ..=input_array. len ( ) as i32 ) . collect :: < Vec < _ > > ( ) ;
447
- let offsets = OffsetBuffer :: new ( ScalarBuffer :: from ( offsets) ) ;
448
+ // Safety: all checks in `OffsetBuffer::new` are ensured to pass
449
+ let offsets = unsafe { OffsetBuffer :: new_unchecked ( ScalarBuffer :: from ( offsets) ) } ;
448
450
449
451
// `nulls` for converted `ListArray`
450
452
let nulls = filtered_null_mask ( opt_filter, input_array) ;
You can’t perform that action at this time.
0 commit comments