@@ -8,7 +8,7 @@ use num_traits::ToPrimitive;
88use vortex_buffer:: { Buffer , BufferMut , ByteBuffer } ;
99use vortex_compute:: filter:: Filter ;
1010use vortex_dtype:: { DType , PTypeDowncastExt , match_each_integer_ptype} ;
11- use vortex_error:: { VortexExpect , VortexResult } ;
11+ use vortex_error:: { VortexExpect , VortexResult , vortex_ensure } ;
1212use vortex_vector:: Vector ;
1313use vortex_vector:: binaryview:: {
1414 BinaryType , BinaryView , BinaryViewType , BinaryViewVector , StringType ,
@@ -113,11 +113,20 @@ impl<V: BinaryViewType> BatchKernel for VarBinKernel<V> {
113113
114114 let views = views. freeze( ) . filter( & selection) ;
115115
116- Ok ( Vector :: from( BinaryViewVector :: <V >:: new(
117- views,
118- Arc :: new( [ self . bytes. clone( ) ] ) ,
119- validity,
120- ) ) )
116+ vortex_ensure!(
117+ validity. len( ) == views. len( ) ,
118+ "mismatched validity and views length"
119+ ) ;
120+
121+ // SAFETY: views were constructed in the loop above to point at valid data from
122+ // the buffer. Validity was checked immediately above to be of the appropriate length.
123+ Ok ( Vector :: from( unsafe {
124+ BinaryViewVector :: <V >:: new_unchecked(
125+ views,
126+ Arc :: new( [ self . bytes. clone( ) ] ) ,
127+ validity,
128+ )
129+ } ) )
121130 } )
122131 }
123132}
0 commit comments