File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -330,6 +330,11 @@ impl ZstdArray {
330330 . get ( i + 1 )
331331 . copied ( )
332332 . unwrap_or ( value_bytes. len ( ) ) ;
333+
334+ // Use slice_unaligned instead of slice to handle cases where frame boundaries
335+ // don't align with the buffer's alignment requirements (e.g., 64-byte aligned
336+ // buffers with 1-byte frame boundaries). ZSTD compression works on raw bytes
337+ // and doesn't require memory alignment.
333338 let uncompressed = & value_bytes. slice ( frame_byte_starts[ i] ..frame_byte_end) ;
334339 let compressed = compressor
335340 . compress ( uncompressed)
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ use vortex_array::arrays::VarBinViewArray;
99use vortex_array:: assert_arrays_eq;
1010use vortex_array:: validity:: Validity ;
1111use vortex_array:: vtable:: ValidityHelper ;
12+ use vortex_buffer:: Alignment ;
1213use vortex_buffer:: Buffer ;
1314use vortex_dtype:: DType ;
1415use vortex_dtype:: Nullability ;
@@ -202,3 +203,16 @@ fn test_sliced_array_children() {
202203 let sliced = compressed. slice ( 0 ..4 ) ;
203204 sliced. children ( ) ;
204205}
206+
207+ #[ test]
208+ fn test_zstd_alignment_issue ( ) {
209+ // Scenario where a u8 array has a 64-byte alignment.
210+ // See: https://github.com/vortex-data/vortex/issues/5715
211+ let data = vec ! [ 0u8 ; 2 ] ;
212+
213+ let aligned_buffer = Buffer :: copy_from_aligned ( & data, Alignment :: new ( 8 ) ) ;
214+ let array = PrimitiveArray :: new ( aligned_buffer, Validity :: NonNullable ) ;
215+ let compressed = ZstdArray :: from_primitive ( & array, 0 , 1 ) ;
216+
217+ assert ! ( compressed. is_ok( ) ) ;
218+ }
You can’t perform that action at this time.
0 commit comments