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

vortex-data / vortex / 16992591828

15 Aug 2025 02:51PM UTC coverage: 87.203% (-0.5%) from 87.72%
16992591828

Pull #2456

github

web-flow
Merge fe7e226a7 into 4a23f65b3
Pull Request #2456: feat: basic BoolBuffer / BoolBufferMut

476 of 1230 new or added lines in 107 files covered. (38.7%)

74 existing lines in 19 files now uncovered.

56525 of 64820 relevant lines covered (87.2%)

623751.88 hits per line

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

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

4
use vortex_error::{VortexResult, vortex_bail};
5
use vortex_mask::Mask;
6
use vortex_scalar::{DecimalValue, Scalar, match_each_decimal_value_type};
7

8
use crate::arrays::{DecimalArray, DecimalVTable};
9
use crate::compute::{SumKernel, SumKernelAdapter};
10
use crate::register_kernel;
11

12
macro_rules! sum_decimal {
13
    ($ty:ty, $values:expr) => {{
14
        let mut sum: $ty = <$ty>::default();
15
        for v in $values {
16
            sum = num_traits::CheckedAdd::checked_add(&sum, &v).expect("overflow");
17
        }
18
        sum
19
    }};
20
    ($ty:ty, $values:expr, $validity:expr) => {{
21
        use itertools::Itertools;
22

23
        let mut sum: $ty = <$ty>::default();
24
        for (v, valid) in $values.iter().zip_eq($validity.iter()) {
25
            if valid {
26
                sum = num_traits::CheckedAdd::checked_add(&sum, &v).expect("overflow");
27
            }
28
        }
29
        sum
30
    }};
31
}
32

33
impl SumKernel for DecimalVTable {
34
    fn sum(&self, array: &DecimalArray) -> VortexResult<Scalar> {
×
35
        let decimal_dtype = array.decimal_dtype();
×
36
        let nullability = array.dtype.nullability();
×
37

38
        match array.validity_mask()? {
×
39
            Mask::AllFalse(_) => {
40
                vortex_bail!("invalid state, all-null array should be checked by top-level sum fn")
×
41
            }
42
            Mask::AllTrue(_) => {
43
                match_each_decimal_value_type!(array.values_type(), |D| {
×
44
                    Ok(Scalar::decimal(
×
45
                        DecimalValue::from(sum_decimal!(D, array.buffer::<D>())),
×
46
                        decimal_dtype,
×
47
                        nullability,
×
48
                    ))
49
                })
50
            }
51
            Mask::Values(mask_values) => {
×
52
                match_each_decimal_value_type!(array.values_type(), |D| {
×
53
                    Ok(Scalar::decimal(
×
54
                        DecimalValue::from(sum_decimal!(
×
55
                            D,
×
56
                            array.buffer::<D>(),
×
NEW
57
                            mask_values.boolean_buffer()
×
58
                        )),
59
                        decimal_dtype,
×
60
                        nullability,
×
61
                    ))
62
                })
63
            }
64
        }
65
    }
×
66
}
67

68
register_kernel!(SumKernelAdapter(DecimalVTable).lift());
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