Commit 72d39fb
Fix patch_chunk index OOB when slicing ALP arrays mid-chunk (#7354)
## Summary
`patch_chunk` panics with index-out-of-bounds when decompressing sliced
ALP arrays with patches. The slice boundary must fall mid-chunk
(non-1024-aligned) to trigger it.
**Root cause:** `Patches::slice()` slices `chunk_offsets` at chunk
granularity but `indices`/`values` at element granularity. When a slice
ends mid-chunk, `patches_end_idx` can exceed `patches_indices.len()`.
The start index already used `saturating_sub` — the end index didn't.
**Fix:**
`.saturating_sub(offset_within_chunk).min(patches_indices.len())` on the
end index computation in `patch_chunk`, `search_index_chunked`, and
`search_index_chunked_batch`.
**AI disclosure:** Root cause analysis, fix implementation, and test
writing were done with Claude Code under my direction and review. I
identified the bug during development benchmarking at 100M rows and
verified the fix against my workload.
## Testing
- Unit test calling `patch_chunk` with inputs that OOB without the fix.
- Integration test: ALP encode 3-chunk array with patches, slice
mid-chunk, decode. Tests both start-aligned and mid-chunk-start
variants.
- All existing tests pass (2538 vortex-array, 167 vortex-alp).
---------
Signed-off-by: Abanoub Doss <abanoub.doss@gmail.com>
Co-authored-by: Abanoub Doss <abanoub.doss@gmail.com>1 parent 957eb3a commit 72d39fb
3 files changed
Lines changed: 82 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
549 | 589 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
114 | 116 | | |
115 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
116 | 120 | | |
117 | 121 | | |
118 | 122 | | |
| |||
135 | 139 | | |
136 | 140 | | |
137 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
138 | 173 | | |
139 | 174 | | |
140 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
463 | | - | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
464 | 466 | | |
465 | 467 | | |
466 | 468 | | |
| |||
522 | 524 | | |
523 | 525 | | |
524 | 526 | | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
| 527 | + | |
531 | 528 | | |
| 529 | + | |
| 530 | + | |
532 | 531 | | |
533 | 532 | | |
534 | 533 | | |
| |||
0 commit comments