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

vortex-data / vortex / 16350502539

17 Jul 2025 04:22PM UTC coverage: 80.836% (-0.7%) from 81.557%
16350502539

Pull #3876

github

web-flow
Merge d8ff9e2c1 into d53d06603
Pull Request #3876: feat[layout]: replace register_splits with a layout splits stream

645 of 692 new or added lines in 17 files covered. (93.21%)

372 existing lines in 117 files now uncovered.

42316 of 52348 relevant lines covered (80.84%)

141734.87 hits per line

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

97.5
/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> {
998✔
17
        let patch_indices = patches.indices().to_primitive()?;
998✔
18
        let patch_values = patches.values().to_primitive()?;
998✔
19

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

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

51
        let patch_indices = patch_indices.as_slice::<I>();
998✔
52
        let patch_values = patch_values.as_slice::<T>();
998✔
53
        for (idx, value) in itertools::zip_eq(patch_indices, patch_values) {
4,398✔
54
            own_values[idx.as_usize() - patch_indices_offset] = *value;
4,398✔
55
        }
4,398✔
56
        Ok(Self::new(own_values, patched_validity))
998✔
57
    }
998✔
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() {
1✔
70
        let input = PrimitiveArray::new(buffer![2u32; 10], Validity::AllValid);
1✔
71
        let sliced = input.slice(2, 8).unwrap();
1✔
72
        assert_eq!(sliced.to_primitive().unwrap().as_slice::<u32>(), &[2u32; 6]);
1✔
73
    }
1✔
74
}
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