File tree Expand file tree Collapse file tree
vortex-array/src/arrays/list Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ use crate::array::child_to_validity;
2828use crate :: array:: validity_to_child;
2929use crate :: arrays:: ConstantArray ;
3030use crate :: arrays:: List ;
31+ use crate :: arrays:: ListArray ;
3132use crate :: arrays:: Primitive ;
3233use crate :: builtins:: ArrayBuiltins ;
3334use crate :: dtype:: DType ;
@@ -338,7 +339,6 @@ pub trait ListArrayExt: TypedArrayRef<List> {
338339 let mut elements = self . sliced_elements ( ) ?;
339340 if recurse && elements. is_canonical ( ) {
340341 let compacted = elements
341- . clone ( )
342342 . execute :: < Canonical > ( ctx) ?
343343 . compact ( ctx) ?
344344 . into_array ( ) ;
@@ -357,7 +357,8 @@ pub trait ListArrayExt: TypedArrayRef<List> {
357357 Operator :: Sub ,
358358 ) ?;
359359
360- Array :: < List > :: try_new ( elements, adjusted_offsets, self . list_validity ( ) )
360+ // SAFETY: By resetting the offsets we simply "shift" everything left and discard trailing garbage, so all invariants remain the same.
361+ Ok ( unsafe { ListArray :: new_unchecked ( elements, adjusted_offsets, self . list_validity ( ) ) } )
361362 }
362363}
363364impl < T : TypedArrayRef < List > > ListArrayExt for T { }
You can’t perform that action at this time.
0 commit comments