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

vortex-data / vortex / 16935267080

13 Aug 2025 11:00AM UTC coverage: 24.312% (-63.3%) from 87.658%
16935267080

Pull #4226

github

web-flow
Merge 81b48c7fb into baa6ea202
Pull Request #4226: Support converting TimestampTZ to and from duckdb

0 of 2 new or added lines in 1 file covered. (0.0%)

20666 existing lines in 469 files now uncovered.

8726 of 35892 relevant lines covered (24.31%)

147.74 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
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> {
70✔
23
        Ok(Self::validity_mask(array)?.true_count())
70✔
24
    }
70✔
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> {
18✔
31
        Ok(Self::validity_mask(array)?.false_count())
18✔
32
    }
18✔
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> {
10✔
50
        array.validity().is_valid(index)
10✔
51
    }
10✔
52

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

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

61
    fn validity_mask(array: &V::Array) -> VortexResult<Mask> {
514✔
62
        array.validity().to_mask(array.len())
514✔
63
    }
514✔
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

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

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

UNCOV
96
    fn validity_mask(array: &V::Array) -> VortexResult<Mask> {
×
UNCOV
97
        array.sliced_validity()?.to_mask(array.len())
×
UNCOV
98
    }
×
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
{
UNCOV
113
    fn is_valid(array: &V::Array, index: usize) -> VortexResult<bool> {
×
UNCOV
114
        V::validity_child(array).is_valid(index)
×
UNCOV
115
    }
×
116

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

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

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