@@ -278,25 +278,28 @@ mod tests {
278278 Ok ( ( ) )
279279 }
280280
281- /// Multi-chunk ALP (> 1024 elements) with patches scattered across chunks.
282- /// Exercises the fused kernel's per-block patches cursor math when more
283- /// than one block is launched.
281+ /// Multi-chunk ALP (> 1024 elements) with patches in chunks 0 and 2 but
282+ /// none in chunk 1. Exercises the `PatchesCursor` branch where a
283+ /// non-trailing chunk has `chunk_offsets[c] == chunk_offsets[c+1]`
284+ /// (zero patches) via the offset math rather than the NULL sentinel.
284285 #[ crate :: test]
285- async fn test_cuda_alp_multi_chunk_with_patches ( ) -> VortexResult < ( ) > {
286+ async fn test_cuda_alp_multi_chunk_sparse_patches ( ) -> VortexResult < ( ) > {
286287 let mut cuda_ctx = CudaSession :: create_execution_ctx ( & VortexSession :: empty ( ) )
287288 . vortex_expect ( "failed to create execution context" ) ;
288289
289290 // 3072 values (3 chunks). Inject exceptions (values ALP can't encode
290- // losslessly) at a handful of positions spread across chunks.
291- let mut values: Vec < f32 > = Vec :: with_capacity ( 3072 ) ;
292- for i in 0u32 ..3072 {
293- if matches ! ( i, 0 | 100 | 1023 | 1024 | 2000 | 3071 ) {
294- values. push ( 1.0_f32 / 7.0 + i as f32 ) ;
295- } else {
296- values. push ( i as f32 ) ;
297- }
298- }
299- let prim = PrimitiveArray :: new ( Buffer :: from ( values) , Validity :: NonNullable ) ;
291+ // losslessly) only in chunks 0 and 2; chunk 1 stays exception-free so
292+ // its cursor slice is empty despite patches existing in the array.
293+ let values: Buffer < f32 > = ( 0u32 ..3072 )
294+ . map ( |i| {
295+ if matches ! ( i, 0 | 100 | 1023 | 3071 ) {
296+ 1.0_f32 / 7.0 + i as f32
297+ } else {
298+ i as f32
299+ }
300+ } )
301+ . collect ( ) ;
302+ let prim = PrimitiveArray :: new ( values, Validity :: NonNullable ) ;
300303 let alp_array = alp_encode (
301304 prim. as_view ( ) ,
302305 None ,
@@ -330,15 +333,16 @@ mod tests {
330333 . vortex_expect ( "failed to create execution context" ) ;
331334
332335 // 3072 values (3 chunks). Sprinkle exceptions into each chunk.
333- let mut values: Vec < f64 > = Vec :: with_capacity ( 3072 ) ;
334- for i in 0u32 ..3072 {
335- if matches ! ( i, 0 | 500 | 1024 | 1500 | 2048 | 3071 ) {
336- values. push ( 1.0_f64 / 3.0 + i as f64 ) ;
337- } else {
338- values. push ( i as f64 ) ;
339- }
340- }
341- let prim = PrimitiveArray :: new ( Buffer :: from ( values) , Validity :: NonNullable ) ;
336+ let values: Buffer < f64 > = ( 0u32 ..3072 )
337+ . map ( |i| {
338+ if matches ! ( i, 0 | 500 | 1024 | 1500 | 2048 | 3071 ) {
339+ 1.0_f64 / 3.0 + i as f64
340+ } else {
341+ i as f64
342+ }
343+ } )
344+ . collect ( ) ;
345+ let prim = PrimitiveArray :: new ( values, Validity :: NonNullable ) ;
342346 let alp_array = alp_encode (
343347 prim. as_view ( ) ,
344348 None ,
@@ -420,15 +424,10 @@ mod tests {
420424 let mut cuda_ctx = CudaSession :: create_execution_ctx ( & VortexSession :: empty ( ) )
421425 . vortex_expect ( "failed to create execution context" ) ;
422426
423- let mut values: Vec < f64 > = Vec :: with_capacity ( 1500 ) ;
424- for i in 0u32 ..1500 {
425- if i == 1400 {
426- values. push ( 1.0_f64 / 3.0 ) ;
427- } else {
428- values. push ( i as f64 ) ;
429- }
430- }
431- let prim = PrimitiveArray :: new ( Buffer :: from ( values) , Validity :: NonNullable ) ;
427+ let values: Buffer < f64 > = ( 0u32 ..1500 )
428+ . map ( |i| if i == 1400 { 1.0_f64 / 3.0 } else { i as f64 } )
429+ . collect ( ) ;
430+ let prim = PrimitiveArray :: new ( values, Validity :: NonNullable ) ;
432431 let alp_array = alp_encode (
433432 prim. as_view ( ) ,
434433 None ,
0 commit comments