Skip to content

Commit a1435a2

Browse files
committed
align frames to buffer
Signed-off-by: Alexander Droste <[email protected]>
1 parent 0bf2e55 commit a1435a2

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

encodings/zstd/src/array.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,6 @@ impl ZstdArray {
331331
.copied()
332332
.unwrap_or(value_bytes.len());
333333

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.
338334
let uncompressed = &value_bytes.slice(frame_byte_starts[i]..frame_byte_end);
339335
let compressed = compressor
340336
.compress(uncompressed)
@@ -371,8 +367,12 @@ impl ZstdArray {
371367
};
372368

373369
let value_bytes = values.byte_buffer();
370+
// Align frames to buffer alignment. This is necessary for overaligned buffers.
371+
let alignment = *value_bytes.alignment();
372+
let step_width = (values_per_frame * byte_width).div_ceil(alignment) * alignment;
373+
374374
let frame_byte_starts = (0..n_values * byte_width)
375-
.step_by(values_per_frame * byte_width)
375+
.step_by(step_width)
376376
.collect::<Vec<_>>();
377377
let Frames {
378378
dictionary,

encodings/zstd/src/test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ fn test_sliced_array_children() {
207207
#[test]
208208
fn 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));

0 commit comments

Comments
 (0)