From fa6d5e171b12cf7cc20fe64744afcc5e7f28b82e Mon Sep 17 00:00:00 2001 From: Jinpeng Date: Thu, 5 Dec 2024 05:41:54 -0500 Subject: [PATCH] avoid redundant parsing of repeated value in RleDecoder (#6834) Co-authored-by: jp0317 --- parquet/src/encodings/rle.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parquet/src/encodings/rle.rs b/parquet/src/encodings/rle.rs index 0c708c126503..d089ba7836e1 100644 --- a/parquet/src/encodings/rle.rs +++ b/parquet/src/encodings/rle.rs @@ -369,17 +369,17 @@ impl RleDecoder { } #[inline(never)] - pub fn get_batch(&mut self, buffer: &mut [T]) -> Result { + pub fn get_batch(&mut self, buffer: &mut [T]) -> Result { assert!(size_of::() <= 8); let mut values_read = 0; while values_read < buffer.len() { if self.rle_left > 0 { let num_values = cmp::min(buffer.len() - values_read, self.rle_left as usize); + let repeated_value = + T::try_from_le_slice(&self.current_value.as_mut().unwrap().to_ne_bytes())?; for i in 0..num_values { - let repeated_value = - T::try_from_le_slice(&self.current_value.as_mut().unwrap().to_ne_bytes())?; - buffer[values_read + i] = repeated_value; + buffer[values_read + i] = repeated_value.clone(); } self.rle_left -= num_values as u32; values_read += num_values;