@@ -74,14 +74,26 @@ impl ListViewArray {
7474 let offsets_ptype = self . offsets ( ) . dtype ( ) . as_ptype ( ) ;
7575 let sizes_ptype = self . sizes ( ) . dtype ( ) . as_ptype ( ) ;
7676
77- match_each_integer_ptype ! ( offsets_ptype, |O | {
78- match_each_integer_ptype!( sizes_ptype, |S | { self . naive_rebuild:: <O , S >( ) } )
77+ match_each_integer_ptype ! ( sizes_ptype, |S | {
78+ match offsets_ptype {
79+ PType :: U8 => self . naive_rebuild:: <u8 , u32 , S >( ) ,
80+ PType :: U16 => self . naive_rebuild:: <u16 , u32 , S >( ) ,
81+ PType :: U32 => self . naive_rebuild:: <u32 , u32 , S >( ) ,
82+ PType :: U64 => self . naive_rebuild:: <u64 , u64 , S >( ) ,
83+ PType :: I8 => self . naive_rebuild:: <i8 , i32 , S >( ) ,
84+ PType :: I16 => self . naive_rebuild:: <i16 , i32 , S >( ) ,
85+ PType :: I32 => self . naive_rebuild:: <i32 , i32 , S >( ) ,
86+ PType :: I64 => self . naive_rebuild:: <i64 , i64 , S >( ) ,
87+ _ => unreachable!( "invalid offsets PType" ) ,
88+ }
7989 } )
8090 }
8191
8292 /// The inner function for `rebuild_zero_copy_to_list`, which naively rebuilds a `ListViewArray`
8393 /// via `append_scalar`.
84- fn naive_rebuild < O : IntegerPType , S : IntegerPType > ( & self ) -> ListViewArray {
94+ fn naive_rebuild < O : IntegerPType , NewOffset : IntegerPType , S : IntegerPType > (
95+ & self ,
96+ ) -> ListViewArray {
8597 let element_dtype = self
8698 . dtype ( )
8799 . as_list_element_opt ( )
@@ -96,12 +108,12 @@ impl ListViewArray {
96108 let offsets_canonical = offsets_canonical. as_slice :: < O > ( ) ;
97109 let sizes_canonical = sizes_canonical. as_slice :: < S > ( ) ;
98110
99- let mut offsets = BufferMut :: < u32 > :: with_capacity ( self . len ( ) ) ;
111+ let mut offsets = BufferMut :: < NewOffset > :: with_capacity ( self . len ( ) ) ;
100112 let mut sizes = BufferMut :: < S > :: with_capacity ( self . len ( ) ) ;
101113
102114 let mut chunks = Vec :: with_capacity ( self . len ( ) ) ;
103115
104- let mut n_elements = 0u32 ;
116+ let mut n_elements = NewOffset :: zero ( ) ;
105117
106118 for index in 0 ..self . len ( ) {
107119 if !self . is_valid ( index) {
@@ -120,7 +132,7 @@ impl ListViewArray {
120132 offsets. push ( n_elements) ;
121133 sizes. push ( size) ;
122134
123- n_elements += size . to_u32 ( ) . vortex_expect ( "to_u32 " ) ;
135+ n_elements += num_traits :: cast ( size ) . vortex_expect ( "cast " ) ;
124136 }
125137
126138 let offsets = offsets. into_array ( ) ;
0 commit comments