1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::array::{Array, BinaryArray, PrimitiveArray};
use crate::offset::Offset;
use super::generic_binary::*;
use super::Index;
pub fn take<O: Offset, I: Index>(
values: &BinaryArray<O>,
indices: &PrimitiveArray<I>,
) -> BinaryArray<O> {
let data_type = values.data_type().clone();
let indices_has_validity = indices.null_count() > 0;
let values_has_validity = values.null_count() > 0;
let (offsets, values, validity) = match (values_has_validity, indices_has_validity) {
(false, false) => {
take_no_validity::<O, I>(values.offsets(), values.values(), indices.values())
}
(true, false) => take_values_validity(values, indices.values()),
(false, true) => take_indices_validity(values.offsets(), values.values(), indices),
(true, true) => take_values_indices_validity(values, indices),
};
BinaryArray::<O>::new(data_type, offsets, values, validity)
}