fabianmurariu commented on code in PR #5573:
URL: https://github.com/apache/arrow-rs/pull/5573#discussion_r1546875743
##########
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 could handle the None case in this PR, the index based ones are a poor fit
for REE I suspect unless the selectivity of the filter is high. I'd need a
benchmark but in short I would prefer to leave it as `TODO`
--
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]