pub fn take_values_validity<O: Offset, I: Index, A: GenericBinaryArray<O>>(
    values: &A,
    indices: &[I],
) -> (Buffer<O>, Buffer<u8>, Option<Bitmap>) {
    let validity_values = values.validity().unwrap();
    let validity = indices
        .iter()
        .map(|index| validity_values.get_bit(index.to_usize()));
    let validity = Bitmap::from_trusted_len_iter(validity);

    let mut length = O::default();

    let offsets = values.offsets();
    let values_values = values.values();

    let mut starts = Vec::<O>::with_capacity(indices.len());
    let offsets = indices.iter().map(|index| {
        let index = index.to_usize();
        let start = offsets[index];
        length += offsets[index + 1] - start;
        starts.push(start);
        length
    });
    let offsets = std::iter::once(O::default()).chain(offsets);
    let offsets = Buffer::from_trusted_len_iter(offsets);

    let buffer = take_values(length, starts.as_slice(), offsets.as_slice(), values_values);

    (offsets, buffer, validity.into())
}
// take implementation when only values contain nulls
take implementation when only values contain nulls
take implementation when only values contain nulls
pub fn take_values_validity<O: Offset, I: Index, A: GenericBinaryArray<O>>(
    values: &A,
    indices: &[I],
) -> (Buffer<O>, Buffer<u8>, Option<Bitmap>) {
    let validity_values = values.validity().unwrap();
    let validity = indices
        .iter()
        .map(|index| validity_values.get_bit(index.to_usize()));
    let validity = Bitmap::from_trusted_len_iter(validity);
    let mut length = O::default();
    let offsets = values.offsets();
    let values_values = values.values();
    let mut starts = Vec::<O>::with_capacity(indices.len());
    let offsets = indices.iter().map(|index| {
        let index = index.to_usize();
        let start = offsets[index];
        length += offsets[index + 1] - start;
        starts.push(start);
        length
    });
    let offsets = std::iter::once(O::default()).chain(offsets);
    let offsets = Buffer::from_trusted_len_iter(offsets);
    let buffer = take_values(length, starts.as_slice(), offsets.as_slice(), values_values);
    (offsets, buffer, validity.into())
}
pub fn take_values_validity < O : Offset , I : Index , A : GenericBinaryArray < O > > ( values : & A , indices : & [ I ] , ) -> ( Buffer < O > , Buffer < u8 > , Option < Bitmap > ) { let validity_values = values . validity ( ) . unwrap ( ) ; let validity = indices . iter ( ) . map ( | index | validity_values . get_bit ( index . to_usize ( ) ) ) ; let validity = Bitmap :: from_trusted_len_iter ( validity ) ; let mut length = O :: default ( ) ; let offsets = values . offsets ( ) ; let values_values = values . values ( ) ; let mut starts = Vec :: < O > :: with_capacity ( indices . len ( ) ) ; let offsets = indices . iter ( ) . map ( | index | { let index = index . to_usize ( ) ; let start = offsets [ index ] ; length += offsets [ index + 1 ] - start ; starts . push ( start ) ; length } ) ; let offsets = std :: iter :: once ( O :: default ( ) ) . chain ( offsets ) ; let offsets = Buffer :: from_trusted_len_iter ( offsets ) ; let buffer = take_values ( length , starts . as_slice ( ) , offsets . as_slice ( ) , values_values ) ; ( offsets , buffer , validity . into ( ) ) }
take implementation when only values contain nulls
take implementation when only values contain nulls
values
&A
indices
&[I]
values
&A
indices
&[I]