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

vortex-data / vortex / 16524157085

25 Jul 2025 02:15PM UTC coverage: 81.694% (-0.06%) from 81.758%
16524157085

Pull #3356

github

web-flow
Merge f8337491a into 45200f15d
Pull Request #3356: Clean up stats propagation for slicing

79 of 106 new or added lines in 12 files covered. (74.53%)

26 existing lines in 12 files now uncovered.

43118 of 52780 relevant lines covered (81.69%)

170587.43 hits per line

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

87.23
/vortex-array/src/vtable/validity.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use vortex_error::VortexResult;
5
use vortex_mask::Mask;
6

7
use crate::Array;
8
use crate::validity::Validity;
9
use crate::vtable::VTable;
10

11
pub trait ValidityVTable<V: VTable> {
12
    fn is_valid(array: &V::Array, index: usize) -> VortexResult<bool>;
13

14
    fn all_valid(array: &V::Array) -> VortexResult<bool>;
15

16
    fn all_invalid(array: &V::Array) -> VortexResult<bool>;
17

18
    /// Returns the number of valid elements in the array.
19
    ///
20
    /// ## Post-conditions
21
    /// - The count is less than or equal to the length of the array.
22
    fn valid_count(array: &V::Array) -> VortexResult<usize> {
56,513✔
23
        Ok(Self::validity_mask(array)?.true_count())
56,513✔
24
    }
56,513✔
25

26
    /// Returns the number of invalid elements in the array.
27
    ///
28
    /// ## Post-conditions
29
    /// - The count is less than or equal to the length of the array.
30
    fn invalid_count(array: &V::Array) -> VortexResult<usize> {
13,615✔
31
        Ok(Self::validity_mask(array)?.false_count())
13,615✔
32
    }
13,615✔
33

34
    fn validity_mask(array: &V::Array) -> VortexResult<Mask>;
35
}
36

37
/// An implementation of the [`ValidityVTable`] for arrays that hold validity as a child array.
38
pub struct ValidityVTableFromValidityHelper;
39

40
/// Expose validity held as a child array.
41
pub trait ValidityHelper {
42
    fn validity(&self) -> &Validity;
43
}
44

45
impl<V: VTable> ValidityVTable<V> for ValidityVTableFromValidityHelper
46
where
47
    V::Array: ValidityHelper,
48
{
49
    fn is_valid(array: &V::Array, index: usize) -> VortexResult<bool> {
6,080,256✔
50
        array.validity().is_valid(index)
6,080,256✔
51
    }
6,080,256✔
52

53
    fn all_valid(array: &V::Array) -> VortexResult<bool> {
3,192,533✔
54
        array.validity().all_valid()
3,192,533✔
55
    }
3,192,533✔
56

57
    fn all_invalid(array: &V::Array) -> VortexResult<bool> {
111,425✔
58
        array.validity().all_invalid()
111,425✔
59
    }
111,425✔
60

61
    fn validity_mask(array: &V::Array) -> VortexResult<Mask> {
331,497✔
62
        array.validity().to_mask(array.len())
331,497✔
63
    }
331,497✔
64
}
65

66
/// An implementation of the [`ValidityVTable`] for arrays that hold an unsliced validity
67
/// and a slice into it.
68
pub struct ValidityVTableFromValiditySliceHelper;
69

70
pub trait ValiditySliceHelper {
71
    fn unsliced_validity_and_slice(&self) -> (&Validity, usize, usize);
72

73
    fn sliced_validity(&self) -> VortexResult<Validity> {
4✔
74
        let (unsliced_validity, start, stop) = self.unsliced_validity_and_slice();
4✔
75
        unsliced_validity.slice(start, stop)
4✔
76
    }
4✔
77
}
78

79
impl<V: VTable> ValidityVTable<V> for ValidityVTableFromValiditySliceHelper
80
where
81
    V::Array: ValiditySliceHelper,
82
{
83
    fn is_valid(array: &V::Array, index: usize) -> VortexResult<bool> {
33✔
84
        let (unsliced_validity, start, _) = array.unsliced_validity_and_slice();
33✔
85
        unsliced_validity.is_valid(start + index)
33✔
86
    }
33✔
87

UNCOV
88
    fn all_valid(array: &V::Array) -> VortexResult<bool> {
×
UNCOV
89
        array.sliced_validity()?.all_valid()
×
UNCOV
90
    }
×
91

UNCOV
92
    fn all_invalid(array: &V::Array) -> VortexResult<bool> {
×
UNCOV
93
        array.sliced_validity()?.all_invalid()
×
UNCOV
94
    }
×
95

96
    fn validity_mask(array: &V::Array) -> VortexResult<Mask> {
4✔
97
        array.sliced_validity()?.to_mask(array.len())
4✔
98
    }
4✔
99
}
100

101
/// An implementation of the [`ValidityVTable`] for arrays that delegate validity entirely
102
/// to a child array.
103
pub struct ValidityVTableFromChild;
104

105
pub trait ValidityChild<V: VTable> {
106
    fn validity_child(array: &V::Array) -> &dyn Array;
107
}
108

109
impl<V: VTable> ValidityVTable<V> for ValidityVTableFromChild
110
where
111
    V: ValidityChild<V>,
112
{
113
    fn is_valid(array: &V::Array, index: usize) -> VortexResult<bool> {
1,478✔
114
        V::validity_child(array).is_valid(index)
1,478✔
115
    }
1,478✔
116

117
    fn all_valid(array: &V::Array) -> VortexResult<bool> {
5,099✔
118
        V::validity_child(array).all_valid()
5,099✔
119
    }
5,099✔
120

121
    fn all_invalid(array: &V::Array) -> VortexResult<bool> {
5,169✔
122
        V::validity_child(array).all_invalid()
5,169✔
123
    }
5,169✔
124

125
    fn validity_mask(array: &V::Array) -> VortexResult<Mask> {
1,087✔
126
        V::validity_child(array).validity_mask()
1,087✔
127
    }
1,087✔
128
}
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