tustvold commented on code in PR #9077:
URL: https://github.com/apache/arrow-rs/pull/9077#discussion_r2655607245


##########
parquet/src/arrow/array_reader/primitive_array.rs:
##########
@@ -274,53 +276,36 @@ where
             // See https://github.com/apache/arrow-rs/issues/7040 for a 
discussion of this
             // issue.
             ArrowType::UInt8 if *(array.data_type()) == ArrowType::Int32 => {
-                let array = array
-                    .as_any()
-                    .downcast_ref::<Int32Array>()
-                    .unwrap()
-                    .unary(|i| i as u8) as UInt8Array;
+                let array = array.as_primitive::<Int32Type>().unary(|i| i as 
u8) as UInt8Array;
                 Arc::new(array) as ArrayRef
             }
             ArrowType::Int8 if *(array.data_type()) == ArrowType::Int32 => {
-                let array = array
-                    .as_any()
-                    .downcast_ref::<Int32Array>()
-                    .unwrap()
-                    .unary(|i| i as i8) as Int8Array;
+                let array = array.as_primitive::<Int32Type>().unary(|i| i as 
i8) as Int8Array;
                 Arc::new(array) as ArrayRef
             }
             ArrowType::UInt16 if *(array.data_type()) == ArrowType::Int32 => {
-                let array = array
-                    .as_any()
-                    .downcast_ref::<Int32Array>()
-                    .unwrap()
-                    .unary(|i| i as u16) as UInt16Array;
+                let array = array.as_primitive::<Int32Type>().unary(|i| i as 
u16) as UInt16Array;
                 Arc::new(array) as ArrayRef
             }
             ArrowType::Int16 if *(array.data_type()) == ArrowType::Int32 => {
-                let array = array
-                    .as_any()
-                    .downcast_ref::<Int32Array>()
-                    .unwrap()
-                    .unary(|i| i as i16) as Int16Array;
+                let array = array.as_primitive::<Int32Type>().unary(|i| i as 
i16) as Int16Array;
                 Arc::new(array) as ArrayRef
             }
             ArrowType::Date64 if *(array.data_type()) == ArrowType::Int32 => {
                 // this is cheap as it internally reinterprets the data
-                let a = arrow_cast::cast(&array, &ArrowType::Date32)?;
+                let a = array
+                    .as_primitive::<Int32Type>()
+                    .reinterpret_cast::<Date32Type>();

Review Comment:
   When not performing a widening / truncating conversion, reinterpret_cast 
will be faster



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to