fn min_max_helper<T, F>(array: &PrimitiveArray<T>, cmp: F) -> Option<T::Native>
where
    T: ArrowNumericType,
    F: Fn(&T::Native, &T::Native) -> bool,
{
    let null_count = array.null_count();

    if null_count == array.len() {
        return None;
    }

    let mut n: T::Native = T::default_value();
    let mut has_value = false;
    let data = array.data();
    let m = array.value_slice(0, data.len());

    if null_count == 0 {
        // optimized path for arrays without null values
        for item in m {
            if !has_value || cmp(&n, item) {
                has_value = true;
                n = *item
            }
        }
    } else {
        for (i, item) in m.iter().enumerate() {
            if data.is_valid(i) && (!has_value || cmp(&n, item)) {
                has_value = true;
                n = *item
            }
        }
    }
    Some(n)
}
/// Helper function to perform min/max lambda function on values from a numeric array.
Helper function to perform min/max lambda function on values from a numeric array.
Helper function to perform min / max lambda function on values from a numeric array .
fn min_max_helper<T, F>(array: &PrimitiveArray<T>, cmp: F) -> Option<T::Native>
where
    T: ArrowNumericType,
    F: Fn(&T::Native, &T::Native) -> bool,
{
    let null_count = array.null_count();
    if null_count == array.len() {
        return None;
    }
    let mut n: T::Native = T::default_value();
    let mut has_value = false;
    let data = array.data();
    let m = array.value_slice(0, data.len());
    if null_count == 0 {
        // optimized path for arrays without null values
        for item in m {
            if !has_value || cmp(&n, item) {
                has_value = true;
                n = *item
            }
        }
    } else {
        for (i, item) in m.iter().enumerate() {
            if data.is_valid(i) && (!has_value || cmp(&n, item)) {
                has_value = true;
                n = *item
            }
        }
    }
    Some(n)
}
fn min_max_helper < T , F > ( array : & PrimitiveArray < T > , cmp : F ) -> Option < T :: Native > where T : ArrowNumericType , F : Fn ( & T :: Native , & T :: Native ) -> bool , { let null_count = array . null_count ( ) ; if null_count == array . len ( ) { return None ; } let mut n : T :: Native = T :: default_value ( ) ; let mut has_value = false ; let data = array . data ( ) ; let m = array . value_slice ( 0 , data . len ( ) ) ; if null_count == 0 { // optimized path for arrays without null values for item in m { if ! has_value || cmp ( & n , item ) { has_value = true ; n = * item } } } else { for ( i , item ) in m . iter ( ) . enumerate ( ) { if data . is_valid ( i ) && ( ! has_value || cmp ( & n , item ) ) { has_value = true ; n = * item } } } Some ( n ) }
Helper function to perform min/max lambda function on values from a numeric array.
Helper function to perform min / max lambda function on values from a numeric array .
array
&PrimitiveArray<T>
cmp
F