• 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

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

4
use arrow_buffer::ArrowNativeType;
5
use itertools::Itertools as _;
6
use vortex_buffer::{Buffer, BufferMut};
7
use vortex_dtype::{DecimalDType, NativePType, match_each_integer_ptype};
8
use vortex_error::{VortexExpect as _, VortexResult, vortex_bail};
9
use vortex_scalar::{BigCast, NativeDecimalType, match_each_decimal_value_type};
10

11
use super::{DecimalArray, compatible_storage_type};
12
use crate::ToCanonical as _;
13
use crate::patches::Patches;
14
use crate::validity::Validity;
15
use crate::vtable::ValidityHelper;
16

17
impl DecimalArray {
18
    #[allow(clippy::cognitive_complexity)]
19
    pub fn patch(self, patches: &Patches) -> VortexResult<Self> {
36✔
20
        let offset = patches.offset();
36✔
21
        let patch_indices = patches.indices().to_primitive()?;
36✔
22
        let patch_values = patches.values().to_decimal()?;
36✔
23

24
        let patched_validity = self.validity().clone().patch(
36✔
25
            self.len(),
36✔
26
            offset,
36✔
27
            patch_indices.as_ref(),
36✔
28
            patch_values.validity(),
36✔
UNCOV
29
        )?;
×
30
        assert_eq!(self.decimal_dtype(), patch_values.decimal_dtype());
36✔
31

32
        match_each_integer_ptype!(patch_indices.ptype(), |I| {
36✔
33
            let patch_indices = patch_indices.as_slice::<I>();
×
34
            match_each_decimal_value_type!(patch_values.values_type(), |PatchDVT| {
×
35
                let patch_values = patch_values.buffer::<PatchDVT>();
×
36
                match_each_decimal_value_type!(self.values_type(), |ValuesDVT| {
×
37
                    let buffer = self.buffer::<ValuesDVT>().into_mut();
×
38
                    patch_typed(
×
39
                        buffer,
×
40
                        self.decimal_dtype(),
×
41
                        patch_indices,
×
42
                        offset,
×
43
                        patch_values,
×
44
                        patched_validity,
×
45
                    )
46
                })
47
            })
48
        })
49
    }
36✔
50
}
51

52
fn patch_typed<I, ValuesDVT, PatchDVT>(
36✔
53
    mut buffer: BufferMut<ValuesDVT>,
36✔
54
    decimal_dtype: DecimalDType,
36✔
55
    patch_indices: &[I],
36✔
56
    patch_indices_offset: usize,
36✔
57
    patch_values: Buffer<PatchDVT>,
36✔
58
    patched_validity: Validity,
36✔
59
) -> VortexResult<DecimalArray>
36✔
60
where
36✔
61
    I: NativePType + ArrowNativeType,
36✔
62
    PatchDVT: NativeDecimalType,
36✔
63
    ValuesDVT: NativeDecimalType,
36✔
64
{
65
    if !compatible_storage_type(ValuesDVT::VALUES_TYPE, decimal_dtype) {
36✔
66
        vortex_bail!(
×
67
            "patch_typed: {:?} cannot represent every value in {}.",
×
68
            ValuesDVT::VALUES_TYPE,
69
            decimal_dtype
70
        )
71
    }
36✔
72

73
    for (idx, value) in patch_indices.iter().zip_eq(patch_values.into_iter()) {
144✔
74
        buffer[idx.as_usize() - patch_indices_offset] = <ValuesDVT as BigCast>::from(value).vortex_expect(
144✔
75
            "values of a given DecimalDType are representable in all compatible NativeDecimalType",
144✔
76
        );
144✔
77
    }
144✔
78

79
    Ok(DecimalArray::new(
36✔
80
        buffer.freeze(),
36✔
81
        decimal_dtype,
36✔
82
        patched_validity,
36✔
83
    ))
36✔
84
}
36✔
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