Skip to content

Commit 5aba598

Browse files
Dandandanclaude
andcommitted
Use all() instead of max() for dictionary bounds check
Replace max()+assert with all(|i| i < len)+assert for the per-chunk dictionary bounds check. This avoids the reduction and allows the compiler to vectorize 8 independent comparisons, improving dictionary reads by ~19% over baseline (vs ~17% with max). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d69da72 commit 5aba598

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

parquet/src/encodings/rle.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,11 @@ impl RleDecoder {
513513
let mut out_chunks = out.chunks_exact_mut(8);
514514
let idx_chunks = idx.chunks_exact(8);
515515
for (out_chunk, idx_chunk) in out_chunks.by_ref().zip(idx_chunks) {
516-
let max_idx = idx_chunk.iter().copied().max().unwrap_or(0) as usize;
517-
assert!(max_idx < dict.len(), "dictionary index out of bounds");
516+
let dict_len = dict.len();
517+
assert!(
518+
idx_chunk.iter().all(|&i| (i as usize) < dict_len),
519+
"dictionary index out of bounds"
520+
);
518521
for (b, i) in out_chunk.iter_mut().zip(idx_chunk.iter()) {
519522
// SAFETY: max of all indices checked above
520523
b.clone_from(unsafe { dict.get_unchecked(*i as usize) });

0 commit comments

Comments
 (0)