Commit 5432766
committed
Fix Misaligned buffer on read by reordering OnPair buffers
Root cause: Vortex's flat-layout segment writer aligns each segment to
the alignment of its *first* buffer only. With the old buffer order
[dict_bytes, dict_offsets, codes, codes_offsets]
`dict_bytes` is variable-length and has no alignment requirement, so
the segment was written u8-aligned. The next buffer (`dict_offsets`)
was a u32 array but ended up at an offset that was only u8-aligned in
the file, and on read `PrimitiveArray<u32>::deserialize` rejected it
with `Misaligned buffer cannot be used to build PrimitiveArray of u32`.
Single-column tests happened to pass because typical OnPair
dictionaries are coincidentally a multiple of 4 bytes; ClickBench's
wide string tables (and TPC-H's `supplier` post-encoding) hit the bad
case.
New buffer order:
Buffer 0 dict_offsets u32[] ← segment alignment = 4
Buffer 1 codes_offsets u32[] ← length already 4-multiple
Buffer 2 codes u16[] ← starts at 4-aligned offset, OK for u16
Buffer 3 dict_bytes u8[] ← variable length, no alignment needed
Each buffer's natural length is a multiple of its alignment, so every
buffer inside the segment stays correctly aligned. The 16-byte
over-copy padding on `dict_bytes` still applies for the decoder.
Verified
* `cargo test -p vortex-onpair -p vortex-btrblocks -p vortex-file`
all green (5 new file-roundtrip tests pass, including a new
`odd_dict_length_alignment` test specifically exercising the
previously-broken case).
* `datafusion-bench tpch --opt scale-factor=0.01 --formats vortex
--queries 1,2,3,6 --iterations 1` runs all four queries
successfully end-to-end (Parquet → Vortex with OnPair → DataFusion).
Signed-off-by: Claude <noreply@anthropic.com>1 parent d229d6e commit 5432766
2 files changed
Lines changed: 80 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
| |||
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
106 | | - | |
107 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
108 | 122 | | |
109 | | - | |
| 123 | + | |
110 | 124 | | |
111 | 125 | | |
112 | 126 | | |
| |||
388 | 402 | | |
389 | 403 | | |
390 | 404 | | |
391 | | - | |
392 | 405 | | |
393 | | - | |
394 | 406 | | |
| 407 | + | |
| 408 | + | |
395 | 409 | | |
396 | 410 | | |
397 | 411 | | |
398 | 412 | | |
399 | 413 | | |
400 | 414 | | |
401 | | - | |
402 | 415 | | |
403 | | - | |
404 | 416 | | |
| 417 | + | |
| 418 | + | |
405 | 419 | | |
406 | 420 | | |
407 | 421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
304 | 353 | | |
305 | 354 | | |
306 | 355 | | |
| |||
0 commit comments