• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vortex-data / vortex / 16992684502

15 Aug 2025 02:56PM UTC coverage: 87.875% (+0.2%) from 87.72%
16992684502

Pull #2456

github

web-flow
Merge 2d540e578 into 4a23f65b3
Pull Request #2456: feat: basic BoolBuffer / BoolBufferMut

1275 of 1428 new or added lines in 110 files covered. (89.29%)

334 existing lines in 31 files now uncovered.

57169 of 65057 relevant lines covered (87.88%)

658056.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.22
/vortex-array/src/arrays/bool/compute/fill_null.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use vortex_error::{VortexResult, vortex_err};
5
use vortex_scalar::Scalar;
6

7
use crate::arrays::{BoolArray, BoolVTable, ConstantArray};
8
use crate::compute::{FillNullKernel, FillNullKernelAdapter};
9
use crate::validity::Validity;
10
use crate::vtable::ValidityHelper;
11
use crate::{ArrayRef, IntoArray, ToCanonical, register_kernel};
12

13
impl FillNullKernel for BoolVTable {
14
    fn fill_null(&self, array: &BoolArray, fill_value: &Scalar) -> VortexResult<ArrayRef> {
1,543✔
15
        let fill = fill_value
1,543✔
16
            .as_bool()
1,543✔
17
            .value()
1,543✔
18
            .ok_or_else(|| vortex_err!("Fill value must be non null"))?;
1,543✔
19

20
        Ok(match array.validity() {
1,543✔
21
            Validity::NonNullable | Validity::AllValid => BoolArray::new(
×
NEW
22
                array.bit_buffer().clone(),
×
23
                fill_value.dtype().nullability().into(),
×
24
            )
×
25
            .into_array(),
×
26
            Validity::AllInvalid => {
27
                ConstantArray::new(fill_value.clone(), array.len()).into_array()
1✔
28
            }
29
            Validity::Array(v) => {
1,542✔
30
                let bool_buffer = if fill {
1,542✔
31
                    array.bit_buffer() | &!v.to_bool()?.bit_buffer()
79✔
32
                } else {
33
                    array.bit_buffer() & v.to_bool()?.bit_buffer()
1,463✔
34
                };
35
                BoolArray::new(bool_buffer, fill_value.dtype().nullability().into()).into_array()
1,542✔
36
            }
37
        })
38
    }
1,543✔
39
}
40

41
register_kernel!(FillNullKernelAdapter(BoolVTable).lift());
42

43
#[cfg(test)]
44
mod tests {
45
    use rstest::rstest;
46
    use vortex_buffer::BitBuffer;
47
    use vortex_dtype::{DType, Nullability};
48

49
    use crate::arrays::BoolArray;
50
    use crate::canonical::ToCanonical;
51
    use crate::compute::fill_null;
52
    use crate::validity::Validity;
53

54
    #[rstest]
55
    #[case(true, vec![true, true, false, true])]
56
    #[case(false, vec![true, false, false, false])]
57
    fn bool_fill_null(#[case] fill_value: bool, #[case] expected: Vec<bool>) {
58
        let bool_array = BoolArray::new(
59
            BitBuffer::from_iter([true, true, false, false]),
60
            Validity::from_iter([true, false, true, false]),
61
        );
62
        let non_null_array = fill_null(bool_array.as_ref(), &fill_value.into())
63
            .unwrap()
64
            .to_bool()
65
            .unwrap();
66
        assert_eq!(
67
            non_null_array.bit_buffer().iter().collect::<Vec<_>>(),
68
            expected
69
        );
70
        assert_eq!(
71
            non_null_array.dtype(),
72
            &DType::Bool(Nullability::NonNullable)
73
        );
74
    }
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc