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

vortex-data / vortex / 16935267080

13 Aug 2025 11:00AM UTC coverage: 24.312% (-63.3%) from 87.658%
16935267080

Pull #4226

github

web-flow
Merge 81b48c7fb into baa6ea202
Pull Request #4226: Support converting TimestampTZ to and from duckdb

0 of 2 new or added lines in 1 file covered. (0.0%)

20666 existing lines in 469 files now uncovered.

8726 of 35892 relevant lines covered (24.31%)

147.74 hits per line

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

0.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)]
UNCOV
16
    pub fn patch(self, patches: &Patches) -> VortexResult<Self> {
×
UNCOV
17
        let patch_indices = patches.indices().to_primitive()?;
×
UNCOV
18
        let patch_values = patches.values().to_primitive()?;
×
19

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

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

UNCOV
51
        let patch_indices = patch_indices.as_slice::<I>();
×
UNCOV
52
        let patch_values = patch_values.as_slice::<T>();
×
UNCOV
53
        for (idx, value) in itertools::zip_eq(patch_indices, patch_values) {
×
UNCOV
54
            own_values[idx.as_usize() - patch_indices_offset] = *value;
×
UNCOV
55
        }
×
UNCOV
56
        Ok(Self::new(own_values, patched_validity))
×
UNCOV
57
    }
×
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 · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc