Jefffrey commented on code in PR #5573:
URL: https://github.com/apache/arrow-rs/pull/5573#discussion_r1547248712


##########
arrow-select/src/filter.rs:
##########
@@ -368,6 +378,86 @@ fn filter_array(values: &dyn Array, predicate: 
&FilterPredicate) -> Result<Array
     }
 }
 
+fn filter_run_end_array<R: RunEndIndexType>(
+    ree_arr: &RunArray<R>,
+    pred: &FilterPredicate,
+) -> Result<ArrayRef, ArrowError> {
+    fn downcast_safe<A: RunEndIndexType, T: RunEndIndexType>(
+        re_arr: &RunArray<A>,
+    ) -> Option<&RunArray<T>> {
+        re_arr.as_any().downcast_ref::<RunArray<T>>()
+    }
+
+    if let Some(ree_array) = downcast_safe::<R, Int64Type>(ree_arr) {
+        let (run_ends, values) = filter_run_end_array_generic(ree_array, 
pred)?;
+        let ree_arr: RunArray<Int64Type> =
+            RunArray::try_new(&PrimitiveArray::from(run_ends), &values)?;
+        Ok(Arc::new(ree_arr))
+    } else if let Some(ree_array) = downcast_safe::<R, Int32Type>(ree_arr) {
+        let (run_ends, values) = filter_run_end_array_generic(ree_array, 
pred)?;
+        let ree_arr: RunArray<Int32Type> =
+            RunArray::try_new(&PrimitiveArray::from(run_ends), &values)?;
+        Ok(Arc::new(ree_arr))
+    } else if let Some(ree_array) = downcast_safe::<R, Int16Type>(ree_arr) {
+        let (run_ends, values) = filter_run_end_array_generic(ree_array, 
pred)?;
+        let ree_arr: RunArray<Int16Type> =
+            RunArray::try_new(&PrimitiveArray::from(run_ends), &values)?;
+        Ok(Arc::new(ree_arr))
+    } else {
+        Err(ArrowError::CastError(
+            "Run ends for RunArray must be i16 or i32 or i64".to_string(),
+        ))
+    }
+}
+
+/// Filter any supported [`RunArray`] based on a [`FilterPredicate`]
+#[allow(clippy::type_complexity)]
+fn filter_run_end_array_generic<R: RunEndIndexType>(
+    re_arr: &RunArray<R>,
+    pred: &FilterPredicate,

Review Comment:
   I think None case is already handled by the parent
   
   
https://github.com/apache/arrow-rs/blob/77a3132bbd27ebb3cef0d79f24a9a839f125343c/arrow-select/src/filter.rs#L318



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