pub(crate) unsafe fn take_list_unchecked(
    values: &ListArray<i64>,
    indices: &UInt32Array,
) -> ListArray<i64> {
    // taking the whole list or a contiguous sublist
    let (list_indices, offsets) = take_value_indices_from_list(values, indices);

    // tmp series so that we can take primitives from it
    let s = Series::try_from(("", values.values().clone() as ArrayRef)).unwrap();
    let taken = s
        .take_unchecked(&UInt32Chunked::new_from_chunks(
            "",
            vec![Arc::new(list_indices) as ArrayRef],
        ))
        .unwrap();
    let taken = taken.chunks()[0].clone();

    let validity =
        if values.null_count() > 0 || indices.null_count() > 0 {
            // determine null buffer, which are a function of `values` and `indices`
            let mut validity = MutableBitmap::with_capacity(indices.len());
            validity.extend_constant(indices.len(), true);

            {
                offsets.as_slice().windows(2).enumerate().for_each(
                    |(i, window): (usize, &[i64])| {
                        if window[0] == window[1] {
                            // offsets are equal, slot is null
                            validity.set(i, false);
                        }
                    },
                );
            }
            Some(validity.into())
        } else {
            None
        };
    ListArray::from_data(values.data_type().clone(), offsets.into(), taken, validity)
}
/// Forked and adapted from arrow-rs
/// This is faster because it does no bounds checks and allocates directly into aligned memory
///
/// # Safety
/// No bounds checks
Forked and adapted from arrow-rs
This is faster because it does no bounds checks and allocates directly into aligned memory
Forked and adapted from arrow - rs This is faster because it does no bounds checks and allocates directly into aligned memory
pub(crate) unsafe fn take_list_unchecked(
    values: &ListArray<i64>,
    indices: &UInt32Array,
) -> ListArray<i64> {
    // taking the whole list or a contiguous sublist
    let (list_indices, offsets) = take_value_indices_from_list(values, indices);
    // tmp series so that we can take primitives from it
    let s = Series::try_from(("", values.values().clone() as ArrayRef)).unwrap();
    let taken = s
        .take_unchecked(&UInt32Chunked::new_from_chunks(
            "",
            vec![Arc::new(list_indices) as ArrayRef],
        ))
        .unwrap();
    let taken = taken.chunks()[0].clone();
    let validity =
        if values.null_count() > 0 || indices.null_count() > 0 {
            // determine null buffer, which are a function of `values` and `indices`
            let mut validity = MutableBitmap::with_capacity(indices.len());
            validity.extend_constant(indices.len(), true);
            {
                offsets.as_slice().windows(2).enumerate().for_each(
                    |(i, window): (usize, &[i64])| {
                        if window[0] == window[1] {
                            // offsets are equal, slot is null
                            validity.set(i, false);
                        }
                    },
                );
            }
            Some(validity.into())
        } else {
            None
        };
    ListArray::from_data(values.data_type().clone(), offsets.into(), taken, validity)
}
pub ( crate ) unsafe fn take_list_unchecked ( values : & ListArray < i64 > , indices : & UInt32Array , ) -> ListArray < i64 > { // taking the whole list or a contiguous sublist let ( list_indices , offsets ) = take_value_indices_from_list ( values , indices ) ; // tmp series so that we can take primitives from it let s = Series :: try_from ( ( " " , values . values ( ) . clone ( ) as ArrayRef ) ) . unwrap ( ) ; let taken = s . take_unchecked ( & UInt32Chunked :: new_from_chunks ( " " , vec ! [ Arc new ( list_indices ) as ArrayRef ] , ) ) . unwrap ( ) ; let taken = taken . chunks ( ) [ 0 ] . clone ( ) ; let validity = if values . null_count ( ) > 0 || indices . null_count ( ) > 0 { // determine null buffer, which are a function of `values` and `indices` let mut validity = MutableBitmap :: with_capacity ( indices . len ( ) ) ; validity . extend_constant ( indices . len ( ) , true ) ; { offsets . as_slice ( ) . windows ( 2 ) . enumerate ( ) . for_each ( | ( i , window ) : ( usize , & [ i64 ] ) | { if window [ 0 ] == window [ 1 ] { // offsets are equal, slot is null validity . set ( i , false ) ; } } , ) ; } Some ( validity . into ( ) ) } else { None } ; ListArray :: from_data ( values . data_type ( ) . clone ( ) , offsets . into ( ) , taken , validity ) }
Forked and adapted from arrow-rs
This is faster because it does no bounds checks and allocates directly into aligned memory
Forked and adapted from arrow - rs This is faster because it does no bounds checks and allocates directly into aligned memory
values
&ListArray<i64>
indices
&UInt32Array
values
&ListArray<i64>
indices
&UInt32Array
safety
No bounds checks
No bounds checks