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

vortex-data / vortex / 16331938722

16 Jul 2025 10:49PM UTC coverage: 80.702% (-0.9%) from 81.557%
16331938722

push

github

web-flow
feat: build with stable rust (#3881)

120 of 173 new or added lines in 28 files covered. (69.36%)

174 existing lines in 102 files now uncovered.

41861 of 51871 relevant lines covered (80.7%)

157487.71 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> {
1,118✔
17
        let patch_indices = patches.indices().to_primitive()?;
1,118✔
18
        let patch_values = patches.values().to_primitive()?;
1,118✔
19

20
        let patched_validity = self.validity().clone().patch(
1,118✔
21
            self.len(),
1,118✔
22
            patches.offset(),
1,118✔
23
            patch_indices.as_ref(),
1,118✔
24
            patch_values.validity(),
1,118✔
UNCOV
25
        )?;
×
26
        match_each_integer_ptype!(patch_indices.ptype(), |I| {
1,118✔
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
    }
1,118✔
37

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

51
        let patch_indices = patch_indices.as_slice::<I>();
1,118✔
52
        let patch_values = patch_values.as_slice::<T>();
1,118✔
53
        for (idx, value) in itertools::zip_eq(patch_indices, patch_values) {
6,362✔
54
            own_values[idx.as_usize() - patch_indices_offset] = *value;
6,362✔
55
        }
6,362✔
56
        Ok(Self::new(own_values, patched_validity))
1,118✔
57
    }
1,118✔
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

© 2025 Coveralls, Inc