From 922aee362f0a9c81d93e4b179cbc5d6237b16457 Mon Sep 17 00:00:00 2001 From: Daniel King Date: Thu, 2 Jan 2025 11:38:11 -0500 Subject: [PATCH] chore: prefer into_buffer_mut() to into_buffer().into_mut() --- encodings/zigzag/src/compress.rs | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/encodings/zigzag/src/compress.rs b/encodings/zigzag/src/compress.rs index 5d838e1a56..54cd68b792 100644 --- a/encodings/zigzag/src/compress.rs +++ b/encodings/zigzag/src/compress.rs @@ -2,7 +2,7 @@ use vortex_array::array::PrimitiveArray; use vortex_array::validity::Validity; use vortex_array::variants::PrimitiveArrayTrait; use vortex_array::IntoArrayData; -use vortex_buffer::Buffer; +use vortex_buffer::BufferMut; use vortex_dtype::{NativePType, PType}; use vortex_error::{vortex_bail, VortexResult}; use zigzag::ZigZag as ExternalZigZag; @@ -12,10 +12,10 @@ use crate::ZigZagArray; pub fn zigzag_encode(parray: PrimitiveArray) -> VortexResult { let validity = parray.validity(); let encoded = match parray.ptype() { - PType::I8 => zigzag_encode_primitive::(parray.into_buffer(), validity), - PType::I16 => zigzag_encode_primitive::(parray.into_buffer(), validity), - PType::I32 => zigzag_encode_primitive::(parray.into_buffer(), validity), - PType::I64 => zigzag_encode_primitive::(parray.into_buffer(), validity), + PType::I8 => zigzag_encode_primitive::(parray.into_buffer_mut(), validity), + PType::I16 => zigzag_encode_primitive::(parray.into_buffer_mut(), validity), + PType::I32 => zigzag_encode_primitive::(parray.into_buffer_mut(), validity), + PType::I64 => zigzag_encode_primitive::(parray.into_buffer_mut(), validity), _ => vortex_bail!( "ZigZag can only encode signed integers, got {}", parray.ptype() @@ -25,25 +25,22 @@ pub fn zigzag_encode(parray: PrimitiveArray) -> VortexResult { } fn zigzag_encode_primitive( - values: Buffer, + values: BufferMut, validity: Validity, ) -> PrimitiveArray where ::UInt: NativePType, { - PrimitiveArray::new( - values.into_mut().map_each(|v| T::encode(v)).freeze(), - validity, - ) + PrimitiveArray::new(values.map_each(|v| T::encode(v)).freeze(), validity) } pub fn zigzag_decode(parray: PrimitiveArray) -> VortexResult { let validity = parray.validity(); let decoded = match parray.ptype() { - PType::U8 => zigzag_decode_primitive::(parray.into_buffer(), validity), - PType::U16 => zigzag_decode_primitive::(parray.into_buffer(), validity), - PType::U32 => zigzag_decode_primitive::(parray.into_buffer(), validity), - PType::U64 => zigzag_decode_primitive::(parray.into_buffer(), validity), + PType::U8 => zigzag_decode_primitive::(parray.into_buffer_mut(), validity), + PType::U16 => zigzag_decode_primitive::(parray.into_buffer_mut(), validity), + PType::U32 => zigzag_decode_primitive::(parray.into_buffer_mut(), validity), + PType::U64 => zigzag_decode_primitive::(parray.into_buffer_mut(), validity), _ => vortex_bail!( "ZigZag can only decode unsigned integers, got {}", parray.ptype() @@ -53,16 +50,13 @@ pub fn zigzag_decode(parray: PrimitiveArray) -> VortexResult { } fn zigzag_decode_primitive( - values: Buffer, + values: BufferMut, validity: Validity, ) -> PrimitiveArray where ::UInt: NativePType, { - PrimitiveArray::new( - values.into_mut().map_each(|v| T::decode(v)).freeze(), - validity, - ) + PrimitiveArray::new(values.map_each(|v| T::decode(v)).freeze(), validity) } #[cfg(test)]