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

vortex-data / vortex / 17073077835

19 Aug 2025 02:40PM UTC coverage: 24.083%. First build
17073077835

Pull #4177

github

web-flow
Merge b42e5758f into 431a8f2b5
Pull Request #4177: feat: ArrayOperations infallible, eager validation + new_unchecked

197 of 1455 new or added lines in 154 files covered. (13.54%)

8646 of 35901 relevant lines covered (24.08%)

142.28 hits per line

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

38.3
/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> {
70✔
24
        Ok(Self::validity_mask(array)?.true_count())
70✔
25
    }
70✔
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> {
14✔
32
        Ok(Self::validity_mask(array)?.false_count())
14✔
33
    }
14✔
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> {
10✔
51
        array.validity().is_valid(index)
10✔
52
    }
10✔
53

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

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

62
    fn validity_mask(array: &V::Array) -> VortexResult<Mask> {
500✔
63
        array.validity().to_mask(array.len())
500✔
64
    }
500✔
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> {
×
115
        V::validity_child(array).is_valid(index)
×
116
    }
×
117

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

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

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