perf: avoid boundary checks on accessing array items (#7570)

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2026-01-14 20:56:39 +08:00
committed by GitHub
parent 170f94fc08
commit a5cb0116a2
6 changed files with 18 additions and 26 deletions

View File

@@ -1174,9 +1174,8 @@ pub(crate) fn decode_primary_keys_with_counts(
let mut result: Vec<(CompositeValues, usize)> = Vec::new();
let mut prev_key: Option<u32> = None;
for i in 0..keys.len() {
let current_key = keys.value(i);
let pk_indices = keys.values();
for &current_key in pk_indices.iter().take(keys.len()) {
// Checks if current key is the same as previous key
if let Some(prev) = prev_key
&& prev == current_key

View File

@@ -563,9 +563,8 @@ pub(crate) fn decode_primary_keys(
// The parquet reader may read the whole dictionary page into the dictionary values, so
// we may decode many primary keys not in this batch if we decode the values array directly.
for i in 0..keys.len() {
let current_key = keys.value(i);
let pk_indices = keys.values();
for &current_key in pk_indices.iter().take(keys.len()) {
// Check if current key is the same as previous key
if let Some(prev) = prev_key
&& prev == current_key