GregBowyer commented on a change in pull request #8698:
URL: https://github.com/apache/arrow/pull/8698#discussion_r534653851



##########
File path: rust/parquet/src/data_type.rs
##########
@@ -558,18 +674,59 @@ pub(crate) mod private {
     macro_rules! impl_from_raw {
         ($ty: ty, $self: ident => $as_i64: block) => {
             impl ParquetValueType for $ty {
-                fn encoded(&self) -> EncodedValue<'_> {
-                    EncodedValue::Bytes { data: as_raw(&*self) }
+                #[inline]
+                fn encode<W: std::io::Write>(values: &[Self], writer: &mut W, 
_: &mut BitWriter) -> Result<()> {
+                    let raw = unsafe {
+                        std::slice::from_raw_parts(
+                            values.as_ptr() as *const u8,
+                            std::mem::size_of::<$ty>() * values.len(),
+                        )
+                    };
+                    writer.write_all(raw)?;
+
+                    Ok(())
+                }
+
+                #[inline]
+                fn set_data(decoder: &mut PlainDecoderDetails, data: 
ByteBufferPtr, num_values: usize) {
+                    decoder.data.replace(data);
+                    decoder.start = 0;
+                    decoder.num_values = num_values;
+                }
+
+                #[inline]
+                fn decode(buffer: &mut [Self], decoder: &mut 
PlainDecoderDetails) -> Result<usize> {
+                    let data = decoder.data.as_mut().unwrap();

Review comment:
       NIT: This should follow the pattern of avoiding the double check by 
using `expect`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to