vortex_array/arrays/bool/
test_harness.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex_error::vortex_panic;
5
6use crate::arrays::BoolArray;
7
8impl BoolArray {
9    pub fn opt_bool_vec(&self) -> Vec<Option<bool>> {
10        self.validity_mask()
11            .to_bit_buffer()
12            .iter()
13            .zip(self.bit_buffer().iter())
14            .map(|(valid, value)| valid.then_some(value))
15            .collect()
16    }
17
18    pub fn bool_vec(&self) -> Vec<bool> {
19        self.validity_mask()
20            .to_bit_buffer()
21            .iter()
22            .zip(self.bit_buffer().iter())
23            .map(|(valid, value)| {
24                if !valid {
25                    vortex_panic!("trying to get bool values from an array with null elements")
26                }
27
28                value
29            })
30            .collect()
31    }
32}