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


##########
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(),
+        ))
+    }

Review Comment:
   The problem I'm having is that I don't know how (or if it is possible) to 
make a PrimitiveArray::from(Vec<R>) as From is defined in term of i64, i32, i16 
and not in generic R::Native.
   
   Or to make a RunArray<R> in the generic version



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