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

vortex-data / vortex / 16728097825

04 Aug 2025 04:00PM UTC coverage: 48.355% (-35.1%) from 83.429%
16728097825

Pull #4108

github

web-flow
Merge 1b2d27fd8 into 649ba9576
Pull Request #4108: perf[vortex-array]: use all_valid instead of `invalid_count() == 0`

1 of 1 new or added line in 1 file covered. (100.0%)

11596 existing lines in 378 files now uncovered.

18635 of 38538 relevant lines covered (48.35%)

151786.4 hits per line

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

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

4
use arrow_buffer::ArrowNativeType;
5
use vortex_dtype::{NativePType, match_each_integer_ptype, match_each_native_ptype};
6
use vortex_error::VortexResult;
7

8
use crate::ToCanonical;
9
use crate::arrays::PrimitiveArray;
10
use crate::patches::Patches;
11
use crate::validity::Validity;
12
use crate::vtable::ValidityHelper;
13

14
impl PrimitiveArray {
15
    #[allow(clippy::cognitive_complexity)]
16
    pub fn patch(self, patches: &Patches) -> VortexResult<Self> {
220✔
17
        let patch_indices = patches.indices().to_primitive()?;
220✔
18
        let patch_values = patches.values().to_primitive()?;
220✔
19

20
        let patched_validity = self.validity().clone().patch(
220✔
21
            self.len(),
220✔
22
            patches.offset(),
220✔
23
            patch_indices.as_ref(),
220✔
24
            patch_values.validity(),
220✔
25
        )?;
×
26
        match_each_integer_ptype!(patch_indices.ptype(), |I| {
220✔
UNCOV
27
            match_each_native_ptype!(self.ptype(), |T| {
×
UNCOV
28
                self.patch_typed::<T, I>(
×
UNCOV
29
                    patch_indices,
×
UNCOV
30
                    patches.offset(),
×
UNCOV
31
                    patch_values,
×
UNCOV
32
                    patched_validity,
×
33
                )
34
            })
35
        })
36
    }
220✔
37

38
    fn patch_typed<T, I>(
220✔
39
        self,
220✔
40
        patch_indices: PrimitiveArray,
220✔
41
        patch_indices_offset: usize,
220✔
42
        patch_values: PrimitiveArray,
220✔
43
        patched_validity: Validity,
220✔
44
    ) -> VortexResult<Self>
220✔
45
    where
220✔
46
        T: NativePType + ArrowNativeType,
220✔
47
        I: NativePType + ArrowNativeType,
220✔
48
    {
49
        let mut own_values = self.into_buffer_mut::<T>();
220✔
50

51
        let patch_indices = patch_indices.as_slice::<I>();
220✔
52
        let patch_values = patch_values.as_slice::<T>();
220✔
53
        for (idx, value) in itertools::zip_eq(patch_indices, patch_values) {
3,690✔
54
            own_values[idx.as_usize() - patch_indices_offset] = *value;
3,690✔
55
        }
3,690✔
56
        Ok(Self::new(own_values, patched_validity))
220✔
57
    }
220✔
58
}
59

60
#[cfg(test)]
61
mod tests {
62
    use vortex_buffer::buffer;
63

64
    use super::*;
65
    use crate::ToCanonical;
66
    use crate::validity::Validity;
67

68
    #[test]
69
    fn patch_sliced() {
70
        let input = PrimitiveArray::new(buffer![2u32; 10], Validity::AllValid);
71
        let sliced = input.slice(2, 8).unwrap();
72
        assert_eq!(sliced.to_primitive().unwrap().as_slice::<u32>(), &[2u32; 6]);
73
    }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc