// take implementation when only indices contain nulls
take implementation when only indices contain nulls
take implementation when only indices contain nulls
pub fn take_indices_validity<O: Offset, I: Index>(
    offsets: &[O],
    values: &[u8],
    indices: &PrimitiveArray<I>,
) -> (Buffer<O>, Buffer<u8>, Option<Bitmap>) {
    let mut length = O::default();
    let mut starts = MutableBuffer::<O>::with_capacity(indices.len());
    let offsets = indices.values().iter().map(|index| {
        let index = index.to_usize();
        match offsets.get(index + 1) {
            Some(&next) => {
                let start = offsets[index];
                length += next - start;
                starts.push(start);
            }
            None => starts.push(O::default()),
        };
        length
    });
    let offsets = std::iter::once(O::default()).chain(offsets);
    let offsets = Buffer::from_trusted_len_iter(offsets);
    let starts: Buffer<O> = starts.into();
    let buffer = take_values(length, starts.as_slice(), offsets.as_slice(), values);
    (offsets, buffer, indices.validity().cloned())
}
pub fn take_indices_validity < O : Offset , I : Index > ( offsets : & [ O ] , values : & [ u8 ] , indices : & PrimitiveArray < I > , ) -> ( Buffer < O > , Buffer < u8 > , Option < Bitmap > ) { let mut length = O :: default ( ) ; let mut starts = MutableBuffer :: < O > :: with_capacity ( indices . len ( ) ) ; let offsets = indices . values ( ) . iter ( ) . map ( | index | { let index = index . to_usize ( ) ; match offsets . get ( index + 1 ) { Some ( & next ) => { let start = offsets [ index ] ; length += next - start ; starts . push ( start ) ; } None => starts . push ( O :: default ( ) ) , } ; length } ) ; let offsets = std :: iter :: once ( O :: default ( ) ) . chain ( offsets ) ; let offsets = Buffer :: from_trusted_len_iter ( offsets ) ; let starts : Buffer < O > = starts . into ( ) ; let buffer = take_values ( length , starts . as_slice ( ) , offsets . as_slice ( ) , values ) ; ( offsets , buffer , indices . validity ( ) . cloned ( ) ) }
take implementation when only indices contain nulls
take implementation when only indices contain nulls
offsets
&[O]
values
&[u8]
indices
&PrimitiveArray<I>