From 0018aff99da281037d72833e3c345b7388c332f5 Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 16 Jul 2026 12:34:58 -0400 Subject: [PATCH] hoist calls for null_sentinel --- arrow-row/src/fixed.rs | 9 ++++++--- arrow-row/src/list.rs | 3 ++- arrow-row/src/variable.rs | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/arrow-row/src/fixed.rs b/arrow-row/src/fixed.rs index d4cd3f8ddef5..ce53eaa1c906 100644 --- a/arrow-row/src/fixed.rs +++ b/arrow-row/src/fixed.rs @@ -221,6 +221,7 @@ pub fn encode( nulls: &NullBuffer, opts: SortOptions, ) { + let null_sentinel = null_sentinel(opts); for (value_idx, is_valid) in nulls.iter().enumerate() { let offset = &mut offsets[value_idx + 1]; let end_offset = *offset + T::ENCODED_LEN; @@ -234,7 +235,7 @@ pub fn encode( } to_write[1..].copy_from_slice(encoded.as_ref()) } else { - data[*offset] = null_sentinel(opts); + data[*offset] = null_sentinel; } *offset = end_offset; } @@ -276,6 +277,7 @@ pub fn encode_boolean( nulls: &NullBuffer, opts: SortOptions, ) { + let null_sentinel = null_sentinel(opts); for (idx, is_valid) in nulls.iter().enumerate() { let offset = &mut offsets[idx + 1]; let end_offset = *offset + bool::ENCODED_LEN; @@ -289,7 +291,7 @@ pub fn encode_boolean( } to_write[1..].copy_from_slice(encoded.as_ref()) } else { - data[*offset] = null_sentinel(opts); + data[*offset] = null_sentinel; } *offset = end_offset; } @@ -327,6 +329,7 @@ pub fn encode_fixed_size_binary( opts: SortOptions, ) { let len = array.value_length() as usize; + let null_sentinel = null_sentinel(opts); for (offset, maybe_val) in offsets.iter_mut().skip(1).zip(array.iter()) { let end_offset = *offset + len + 1; if let Some(val) = maybe_val { @@ -338,7 +341,7 @@ pub fn encode_fixed_size_binary( to_write[1..1 + len].iter_mut().for_each(|v| *v = !*v) } } else { - data[*offset] = null_sentinel(opts); + data[*offset] = null_sentinel; } *offset = end_offset; } diff --git a/arrow-row/src/list.rs b/arrow-row/src/list.rs index ec15192ab3bb..c35e614a9fe0 100644 --- a/arrow-row/src/list.rs +++ b/arrow-row/src/list.rs @@ -547,9 +547,10 @@ pub unsafe fn decode_list_view( } O::from_usize(child_count).expect("overflow"); + let null_sentinel = null_sentinel(opts); let mut null_count = 0; let nulls = MutableBuffer::collect_bool(rows.len(), |x| { - let valid = rows[x][0] != null_sentinel(opts); + let valid = rows[x][0] != null_sentinel; null_count += !valid as usize; valid }); diff --git a/arrow-row/src/variable.rs b/arrow-row/src/variable.rs index ca9700b90fc1..f196e0e22091 100644 --- a/arrow-row/src/variable.rs +++ b/arrow-row/src/variable.rs @@ -336,6 +336,7 @@ fn decode_binary_view_inner( Vec::new() }; + let null_sentinel = null_sentinel(options); let mut views = vec![0_u128; len]; for (i, row) in rows.iter_mut().enumerate() { let start_offset = values.len(); @@ -344,7 +345,7 @@ fn decode_binary_view_inner( // overwrite short strings in the values buffer as we inline those to // views. let decoded_len = values.len() - start_offset; - if row[0] == null_sentinel(options) { + if row[0] == null_sentinel { debug_assert_eq!(offset, 1); debug_assert_eq!(start_offset, values.len()); } else {