@@ -17,14 +17,11 @@ use vortex_array::ArrayParts;
1717use vortex_array:: ArrayRef ;
1818use vortex_array:: ArraySlots ;
1919use vortex_array:: ArrayView ;
20- use vortex_array:: Canonical ;
2120use vortex_array:: EqMode ;
2221use vortex_array:: ExecutionCtx ;
2322use vortex_array:: ExecutionResult ;
2423use vortex_array:: IntoArray ;
25- use vortex_array:: LEGACY_SESSION ;
2624use vortex_array:: TypedArrayRef ;
27- use vortex_array:: VortexSessionExecute ;
2825use vortex_array:: arrays:: Primitive ;
2926use vortex_array:: arrays:: PrimitiveArray ;
3027use vortex_array:: buffer:: BufferHandle ;
@@ -217,13 +214,6 @@ impl VTable for ALPRD {
217214 )
218215 } )
219216 . transpose ( ) ?;
220- // NOTE: `VTable::deserialize` has a fixed trait signature without `ExecutionCtx`, so we
221- // cannot plumb a ctx in here. We construct a legacy ctx locally at this trait boundary.
222- let left_parts_patches = ALPRDData :: canonicalize_patches (
223- & left_parts,
224- left_parts_patches,
225- & mut LEGACY_SESSION . create_execution_ctx ( ) ,
226- ) ?;
227217 let slots = ALPRDData :: make_slots ( & left_parts, & right_parts, left_parts_patches. as_ref ( ) ) ;
228218 let data = ALPRDData :: new (
229219 left_parts_dictionary,
@@ -376,11 +366,8 @@ impl ALPRD {
376366 right_parts : ArrayRef ,
377367 right_bit_width : u8 ,
378368 left_parts_patches : Option < Patches > ,
379- ctx : & mut ExecutionCtx ,
380369 ) -> VortexResult < ALPRDArray > {
381370 let len = left_parts. len ( ) ;
382- let left_parts_patches =
383- ALPRDData :: canonicalize_patches ( & left_parts, left_parts_patches, ctx) ?;
384371 let slots = ALPRDData :: make_slots ( & left_parts, & right_parts, left_parts_patches. as_ref ( ) ) ;
385372 let data = ALPRDData :: new ( left_parts_dictionary, right_bit_width, left_parts_patches) ;
386373 Array :: try_from_parts ( ArrayParts :: new ( ALPRD , dtype, len, data) . with_slots ( slots) )
@@ -408,28 +395,6 @@ impl ALPRD {
408395}
409396
410397impl ALPRDData {
411- fn canonicalize_patches (
412- left_parts : & ArrayRef ,
413- left_parts_patches : Option < Patches > ,
414- ctx : & mut ExecutionCtx ,
415- ) -> VortexResult < Option < Patches > > {
416- left_parts_patches
417- . map ( |patches| {
418- if !patches. values ( ) . all_valid ( ctx) ? {
419- vortex_bail ! ( "patches must be all valid: {}" , patches. values( ) ) ;
420- }
421- // TODO(ngates): assert the DType, don't cast it.
422- // TODO(joe): assert the DType, don't cast it in the next PR.
423- let mut patches = patches. cast_values ( & left_parts. dtype ( ) . as_nonnullable ( ) ) ?;
424- // Force execution of the lazy cast so patch values are materialized
425- // before serialization.
426- let canonical = patches. values ( ) . clone ( ) . execute :: < Canonical > ( ctx) ?;
427- * patches. values_mut ( ) = canonical. into_array ( ) ;
428- Ok ( patches)
429- } )
430- . transpose ( )
431- }
432-
433398 /// Build a new `ALPRDArray` from components.
434399 pub fn new (
435400 left_parts_dictionary : Buffer < u16 > ,
@@ -556,18 +521,16 @@ fn validate_parts(
556521 "patches array_len {} != outer len {len}" ,
557522 patches. array_len( ) ,
558523 ) ;
524+ // Left-parts exceptions are always all-valid and are stored as the non-nullable left-parts
525+ // dtype. Requiring that exact dtype (rather than ignoring nullability) means each
526+ // construction path must produce correct patches, removing the need to normalize them.
527+ // Non-nullable also implies all-valid, so no separate validity check is required.
528+ let expected = left_parts. dtype ( ) . as_nonnullable ( ) ;
559529 vortex_ensure ! (
560- patches. dtype( ) . eq_ignore_nullability ( left_parts . dtype ( ) ) ,
561- "patches dtype {} does not match left_parts dtype {}" ,
530+ patches. dtype( ) == & expected ,
531+ "patches dtype {} must be the non-nullable left_parts dtype {}" ,
562532 patches. dtype( ) ,
563- left_parts. dtype( ) ,
564- ) ;
565- vortex_ensure ! (
566- patches
567- . values( )
568- . all_valid( & mut LEGACY_SESSION . create_execution_ctx( ) ) ?,
569- "patches must be all valid: {}" ,
570- patches. values( )
533+ expected,
571534 ) ;
572535 }
573536
@@ -672,7 +635,7 @@ mod test {
672635 // Pick a seed that we know will trigger lots of patches.
673636 let encoder: alp_rd:: RDEncoder = alp_rd:: RDEncoder :: new ( & [ seed. powi ( -2 ) ] ) ;
674637
675- let rd_array = encoder. encode ( real_array. as_view ( ) , & mut ctx ) ;
638+ let rd_array = encoder. encode ( real_array. as_view ( ) ) ;
676639
677640 let decoded = rd_array
678641 . as_array ( )
0 commit comments