pub fn take_values_indices_validity<O: Offset, I: Index, A: GenericBinaryArray<O>>(
    values: &A,
    indices: &PrimitiveArray<I>,
) -> (Buffer<O>, Buffer<u8>, Option<Bitmap>) {
    let mut length = O::default();
    let mut validity = MutableBitmap::with_capacity(indices.len());

    let values_validity = values.validity().unwrap();
    let offsets = values.offsets();
    let values_values = values.values();

    let mut starts = Vec::<O>::with_capacity(indices.len());
    let offsets = indices.iter().map(|index| {
        match index {
            Some(index) => {
                let index = index.to_usize();
                if values_validity.get_bit(index) {
                    validity.push(true);
                    length += offsets[index + 1] - offsets[index];
                    starts.push(offsets[index]);
                } else {
                    validity.push(false);
                    starts.push(O::default());
                }
            }
            None => {
                validity.push(false);
                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_values);

    (offsets, buffer, validity.into())
}
// take implementation when both indices and values contain nulls
take implementation when both indices and values contain nulls
take implementation when both indices and values contain nulls
pub fn take_values_indices_validity<O: Offset, I: Index, A: GenericBinaryArray<O>>(
    values: &A,
    indices: &PrimitiveArray<I>,
) -> (Buffer<O>, Buffer<u8>, Option<Bitmap>) {
    let mut length = O::default();
    let mut validity = MutableBitmap::with_capacity(indices.len());
    let values_validity = values.validity().unwrap();
    let offsets = values.offsets();
    let values_values = values.values();
    let mut starts = Vec::<O>::with_capacity(indices.len());
    let offsets = indices.iter().map(|index| {
        match index {
            Some(index) => {
                let index = index.to_usize();
                if values_validity.get_bit(index) {
                    validity.push(true);
                    length += offsets[index + 1] - offsets[index];
                    starts.push(offsets[index]);
                } else {
                    validity.push(false);
                    starts.push(O::default());
                }
            }
            None => {
                validity.push(false);
                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_values);
    (offsets, buffer, validity.into())
}
pub fn take_values_indices_validity < O : Offset , I : Index , A : GenericBinaryArray < O > > ( values : & A , indices : & PrimitiveArray < I > , ) -> ( Buffer < O > , Buffer < u8 > , Option < Bitmap > ) { let mut length = O :: default ( ) ; let mut validity = MutableBitmap :: with_capacity ( indices . len ( ) ) ; let values_validity = values . validity ( ) . unwrap ( ) ; let offsets = values . offsets ( ) ; let values_values = values . values ( ) ; let mut starts = Vec :: < O > :: with_capacity ( indices . len ( ) ) ; let offsets = indices . iter ( ) . map ( | index | { match index { Some ( index ) => { let index = index . to_usize ( ) ; if values_validity . get_bit ( index ) { validity . push ( true ) ; length += offsets [ index + 1 ] - offsets [ index ] ; starts . push ( offsets [ index ] ) ; } else { validity . push ( false ) ; starts . push ( O :: default ( ) ) ; } } None => { validity . push ( false ) ; 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_values ) ; ( offsets , buffer , validity . into ( ) ) }
take implementation when both indices and values contain nulls
take implementation when both indices and values contain nulls
values
&A
indices
&PrimitiveArray<I>
values
&A
indices
&PrimitiveArray<I>