File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 33
44use std:: fmt:: Debug ;
55use std:: hash:: Hash ;
6+ use std:: ops:: Div ;
67use std:: ops:: Range ;
78use std:: sync:: Arc ;
89
@@ -331,10 +332,6 @@ impl ZstdArray {
331332 . copied ( )
332333 . unwrap_or ( value_bytes. len ( ) ) ;
333334
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.
338335 let uncompressed = & value_bytes. slice ( frame_byte_starts[ i] ..frame_byte_end) ;
339336 let compressed = compressor
340337 . compress ( uncompressed)
@@ -371,8 +368,14 @@ impl ZstdArray {
371368 } ;
372369
373370 let value_bytes = values. byte_buffer ( ) ;
371+ let step_bytes = values_per_frame * byte_width;
372+ // Align frames to buffer alignment. This isnecessary for overaligned buffers.
373+ // See: https://github.com/vortex-data/vortex/issues/5715
374+ let alignment = * value_bytes. alignment ( ) ;
375+ let step_width = step_bytes. div_ceil ( alignment) * alignment;
376+
374377 let frame_byte_starts = ( 0 ..n_values * byte_width)
375- . step_by ( values_per_frame * byte_width )
378+ . step_by ( step_width )
376379 . collect :: < Vec < _ > > ( ) ;
377380 let Frames {
378381 dictionary,
Original file line number Diff line number Diff line change @@ -207,7 +207,6 @@ fn test_sliced_array_children() {
207207#[ test]
208208fn test_zstd_alignment_issue ( ) {
209209 // Scenario where a u8 array has a 64-byte alignment.
210- // See: https://github.com/vortex-data/vortex/issues/5715
211210 let data = vec ! [ 0u8 ; 2 ] ;
212211
213212 let aligned_buffer = Buffer :: copy_from_aligned ( & data, Alignment :: new ( 8 ) ) ;
You can’t perform that action at this time.
0 commit comments