• 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

5.26
/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 {
2✔
39
        EncodingId::new_ref("vortex.null")
2✔
40
    }
2✔
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 {
×
82
        Self {
×
83
            len,
×
84
            stats_set: Default::default(),
×
85
        }
×
86
    }
×
87
}
88

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

94
    fn dtype(_array: &NullArray) -> &DType {
×
95
        &DType::Null
×
96
    }
×
97

98
    fn stats(array: &NullArray) -> StatsSetRef<'_> {
×
99
        array.stats_set.to_ref(array.as_ref())
×
100
    }
×
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> {
×
130
        Ok(Canonical::Null(array.clone()))
×
131
    }
×
132
}
133

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

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

144
impl ValidityVTable<NullVTable> for NullVTable {
145
    fn is_valid(_array: &NullArray, _index: usize) -> VortexResult<bool> {
×
146
        Ok(false)
×
147
    }
×
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> {
×
158
        Ok(Mask::AllFalse(array.len))
×
159
    }
×
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