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

vortex-data / vortex / 16979224669

14 Aug 2025 11:42PM UTC coverage: 23.728%. First build
16979224669

Pull #2456

github

web-flow
Merge 30049dfa7 into aaf3e36ad
Pull Request #2456: feat: basic BoolBuffer / BoolBufferMut

68 of 1065 new or added lines in 82 files covered. (6.38%)

8616 of 36312 relevant lines covered (23.73%)

146.37 hits per line

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

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

4
use itertools::Itertools;
5
use vortex_dtype::match_each_integer_ptype;
6
use vortex_error::VortexResult;
7

8
use crate::ToCanonical;
9
use crate::arrays::BoolArray;
10
use crate::patches::Patches;
11
use crate::vtable::ValidityHelper;
12

13
impl BoolArray {
14
    pub fn patch(self, patches: &Patches) -> VortexResult<Self> {
×
15
        let len = self.len();
×
16
        let offset = patches.offset();
×
17
        let indices = patches.indices().to_primitive()?;
×
18
        let values = patches.values().to_bool()?;
×
19

20
        let patched_validity =
×
21
            self.validity()
×
22
                .clone()
×
23
                .patch(len, offset, indices.as_ref(), values.validity())?;
×
24

NEW
25
        let (mut own_values, bit_offset) = self.into_bit_buffer().into_mut();
×
26
        match_each_integer_ptype!(indices.ptype(), |I| {
×
27
            for (idx, value) in indices
×
28
                .as_slice::<I>()
×
29
                .iter()
×
NEW
30
                .zip_eq(values.bit_buffer().iter())
×
31
            {
×
32
                #[allow(clippy::cast_possible_truncation)]
×
NEW
33
                own_values.set_to(*idx as usize - offset + bit_offset, value);
×
34
            }
×
35
        });
36

37
        Ok(Self::new(
×
NEW
38
            own_values.freeze().slice(bit_offset, len),
×
39
            patched_validity,
×
40
        ))
×
41
    }
×
42
}
43

44
#[cfg(test)]
45
mod tests {
46
    use vortex_buffer::BitBuffer;
47

48
    use crate::ToCanonical;
49
    use crate::arrays::BoolArray;
50

51
    #[test]
52
    fn patch_sliced_bools() {
53
        let arr = BoolArray::from(BitBuffer::new_set(12));
54
        let sliced = arr.slice(4, 12).unwrap();
55
        let (values, offset) = sliced.to_bool().unwrap().into_bit_buffer().into_mut();
56
        assert_eq!(offset, 4);
57
        assert_eq!(values.len(), 12);
58
        assert_eq!(values.as_slice(), &[255, 15]);
59
    }
60

61
    #[test]
62
    fn patch_sliced_bools_offset() {
63
        let arr = BoolArray::from(BitBuffer::new_set(15));
64
        let sliced = arr.slice(4, 15).unwrap();
65
        let (values, offset) = sliced.to_bool().unwrap().into_bit_buffer().into_mut();
66
        assert_eq!(offset, 4);
67
        assert_eq!(values.as_slice(), &[255, 127]);
68
    }
69
}
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