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

vortex-data / vortex / 16598973893

29 Jul 2025 02:25PM UTC coverage: 82.692% (-0.01%) from 82.703%
16598973893

push

github

web-flow
Clean up stats propagation for slicing (#3356)

Reduces the amount we copy some stats (by removing into_iter that forces
a full stats copy)

---------

Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Robert Kruszewski <github@robertk.io>
Signed-off-by: Will Manning <will@willmanning.io>
Co-authored-by: Robert Kruszewski <github@robertk.io>
Co-authored-by: Will Manning <will@willmanning.io>

130 of 157 new or added lines in 15 files covered. (82.8%)

30 existing lines in 13 files now uncovered.

45215 of 54679 relevant lines covered (82.69%)

184610.34 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> {
58,034✔
23
        Ok(Self::validity_mask(array)?.true_count())
58,034✔
24
    }
58,034✔
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> {
15,318✔
31
        Ok(Self::validity_mask(array)?.false_count())
15,318✔
32
    }
15,318✔
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> {
8,542,109✔
50
        array.validity().is_valid(index)
8,542,109✔
51
    }
8,542,109✔
52

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

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

61
    fn validity_mask(array: &V::Array) -> VortexResult<Mask> {
415,128✔
62
        array.validity().to_mask(array.len())
415,128✔
63
    }
415,128✔
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> {
5,026✔
114
        V::validity_child(array).is_valid(index)
5,026✔
115
    }
5,026✔
116

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

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

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