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

vortex-data / vortex / 17075133033

19 Aug 2025 04:01PM UTC coverage: 87.949% (+0.09%) from 87.856%
17075133033

push

github

web-flow
feat: ArrayOperations infallible, eager validation + new_unchecked (#4177)

ArrayOperations currently return VortexResult<>, but they really should
just be infallible. A failed array op is generally indicative of
programmer or encoding error. There's really nothing interesting we can
do to handle an out-of-bounds slice() or scalar_at.

There's a lot that falls out of this, like fixing a bunch of tests,
tweaking our scalar value casting to return Option instead of Result,
etc.

---------

Signed-off-by: Andrew Duffy <andrew@a10y.dev>

1744 of 1985 new or added lines in 195 files covered. (87.86%)

36 existing lines in 27 files now uncovered.

56745 of 64520 relevant lines covered (87.95%)

624082.56 hits per line

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

52.63
/vortex-array/src/arrays/null/mod.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use vortex_buffer::ByteBuffer;
5
use vortex_dtype::DType;
6
use vortex_error::VortexResult;
7
use vortex_mask::Mask;
8
use vortex_scalar::Scalar;
9

10
use crate::serde::ArrayChildren;
11
use crate::stats::{ArrayStats, StatsSetRef};
12
use crate::vtable::{
13
    ArrayVTable, CanonicalVTable, NotSupported, OperationsVTable, SerdeVTable, VTable,
14
    ValidityVTable, VisitorVTable,
15
};
16
use crate::{
17
    ArrayBufferVisitor, ArrayChildVisitor, ArrayRef, Canonical, EmptyMetadata, EncodingId,
18
    EncodingRef, IntoArray, vtable,
19
};
20

21
mod compute;
22

23
vtable!(Null);
24

25
impl VTable for NullVTable {
26
    type Array = NullArray;
27
    type Encoding = NullEncoding;
28

29
    type ArrayVTable = Self;
30
    type CanonicalVTable = Self;
31
    type OperationsVTable = Self;
32
    type ValidityVTable = Self;
33
    type VisitorVTable = Self;
34
    type ComputeVTable = NotSupported;
35
    type EncodeVTable = NotSupported;
36
    type SerdeVTable = Self;
37

38
    fn id(_encoding: &Self::Encoding) -> EncodingId {
868,654✔
39
        EncodingId::new_ref("vortex.null")
868,654✔
40
    }
868,654✔
41

42
    fn encoding(_array: &Self::Array) -> EncodingRef {
×
43
        EncodingRef::new_ref(NullEncoding.as_ref())
×
44
    }
×
45
}
46

47
/// A array where all values are null.
48
///
49
/// This mirrors the Apache Arrow Null array encoding and provides an efficient representation
50
/// for arrays containing only null values. No actual data is stored, only the length.
51
///
52
/// All operations on null arrays return null values or indicate invalid data.
53
///
54
/// # Examples
55
///
56
/// ```
57
/// use vortex_array::arrays::NullArray;
58
/// use vortex_array::IntoArray;
59
///
60
/// // Create a null array with 5 elements
61
/// let array = NullArray::new(5);
62
///
63
/// // Slice the array - still contains nulls
64
/// let sliced = array.slice(1, 3);
65
/// assert_eq!(sliced.len(), 2);
66
///
67
/// // All elements are null
68
/// let scalar = array.scalar_at(0);
69
/// assert!(scalar.is_null());
70
/// ```
71
#[derive(Clone, Debug)]
72
pub struct NullArray {
73
    len: usize,
74
    stats_set: ArrayStats,
75
}
76

77
#[derive(Clone, Debug)]
78
pub struct NullEncoding;
79

80
impl NullArray {
81
    pub fn new(len: usize) -> Self {
153✔
82
        Self {
153✔
83
            len,
153✔
84
            stats_set: Default::default(),
153✔
85
        }
153✔
86
    }
153✔
87
}
88

89
impl ArrayVTable<NullVTable> for NullVTable {
90
    fn len(array: &NullArray) -> usize {
27,244✔
91
        array.len
27,244✔
92
    }
27,244✔
93

94
    fn dtype(_array: &NullArray) -> &DType {
12,811✔
95
        &DType::Null
12,811✔
96
    }
12,811✔
97

98
    fn stats(array: &NullArray) -> StatsSetRef<'_> {
271✔
99
        array.stats_set.to_ref(array.as_ref())
271✔
100
    }
271✔
101
}
102

103
impl SerdeVTable<NullVTable> for NullVTable {
104
    type Metadata = EmptyMetadata;
105

106
    fn metadata(_array: &NullArray) -> VortexResult<Option<Self::Metadata>> {
×
107
        Ok(Some(EmptyMetadata))
×
108
    }
×
109

110
    fn build(
×
111
        _encoding: &NullEncoding,
×
112
        _dtype: &DType,
×
113
        len: usize,
×
114
        _metadata: &Self::Metadata,
×
115
        _buffers: &[ByteBuffer],
×
116
        _children: &dyn ArrayChildren,
×
117
    ) -> VortexResult<NullArray> {
×
118
        Ok(NullArray::new(len))
×
119
    }
×
120
}
121

122
impl VisitorVTable<NullVTable> for NullVTable {
123
    fn visit_buffers(_array: &NullArray, _visitor: &mut dyn ArrayBufferVisitor) {}
×
124

125
    fn visit_children(_array: &NullArray, _visitor: &mut dyn ArrayChildVisitor) {}
×
126
}
127

128
impl CanonicalVTable<NullVTable> for NullVTable {
129
    fn canonicalize(array: &NullArray) -> VortexResult<Canonical> {
46✔
130
        Ok(Canonical::Null(array.clone()))
46✔
131
    }
46✔
132
}
133

134
impl OperationsVTable<NullVTable> for NullVTable {
135
    fn slice(_array: &NullArray, start: usize, stop: usize) -> ArrayRef {
13✔
136
        NullArray::new(stop - start).into_array()
13✔
137
    }
13✔
138

NEW
139
    fn scalar_at(_array: &NullArray, _index: usize) -> Scalar {
×
NEW
140
        Scalar::null(DType::Null)
×
UNCOV
141
    }
×
142
}
143

144
impl ValidityVTable<NullVTable> for NullVTable {
145
    fn is_valid(_array: &NullArray, _index: usize) -> VortexResult<bool> {
12,102✔
146
        Ok(false)
12,102✔
147
    }
12,102✔
148

149
    fn all_valid(array: &NullArray) -> VortexResult<bool> {
×
150
        Ok(array.is_empty())
×
151
    }
×
152

153
    fn all_invalid(array: &NullArray) -> VortexResult<bool> {
×
154
        Ok(!array.is_empty())
×
155
    }
×
156

157
    fn validity_mask(array: &NullArray) -> VortexResult<Mask> {
9✔
158
        Ok(Mask::AllFalse(array.len))
9✔
159
    }
9✔
160
}
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