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

vortex-data / vortex / 17050456606

18 Aug 2025 07:32PM UTC coverage: 47.596%. First build
17050456606

Pull #4177

github

GitHub
Merge afbf04d54 into 7eb8ac9fa
Pull Request #4177:

555 of 1372 new or added lines in 154 files covered. (40.45%)

18648 of 39180 relevant lines covered (47.6%)

234900.69 hits per line

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

63.83
/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
// TODO(aduffy): these methods should be infallible.
12
pub trait ValidityVTable<V: VTable> {
13
    fn is_valid(array: &V::Array, index: usize) -> VortexResult<bool>;
14

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

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

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

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

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

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

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

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

54
    fn all_valid(array: &V::Array) -> VortexResult<bool> {
49,626✔
55
        array.validity().all_valid()
49,626✔
56
    }
49,626✔
57

58
    fn all_invalid(array: &V::Array) -> VortexResult<bool> {
34,032✔
59
        array.validity().all_invalid()
34,032✔
60
    }
34,032✔
61

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

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

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

NEW
74
    fn sliced_validity(&self) -> Validity {
×
75
        let (unsliced_validity, start, stop) = self.unsliced_validity_and_slice();
×
76
        unsliced_validity.slice(start, stop)
×
77
    }
×
78
}
79

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

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

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

97
    fn validity_mask(array: &V::Array) -> VortexResult<Mask> {
×
NEW
98
        array.sliced_validity().to_mask(array.len())
×
99
    }
×
100
}
101

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

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

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

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

122
    fn all_invalid(array: &V::Array) -> VortexResult<bool> {
6,018✔
123
        V::validity_child(array).all_invalid()
6,018✔
124
    }
6,018✔
125

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