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

vortex-data / vortex / 16593958537

29 Jul 2025 10:48AM UTC coverage: 82.285% (+0.5%) from 81.796%
16593958537

Pull #4036

github

web-flow
Merge 04147cb0f into 348079fc3
Pull Request #4036: varbinview builder buffer deduplication

146 of 154 new or added lines in 2 files covered. (94.81%)

348 existing lines in 26 files now uncovered.

44470 of 54044 relevant lines covered (82.28%)

169522.95 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 {
84,631✔
39
        EncodingId::new_ref("vortex.null")
84,631✔
40
    }
84,631✔
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).unwrap();
65
/// assert_eq!(sliced.len(), 2);
66
///
67
/// // All elements are null
68
/// let scalar = array.scalar_at(0).unwrap();
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 {
34✔
82
        Self {
34✔
83
            len,
34✔
84
            stats_set: Default::default(),
34✔
85
        }
34✔
86
    }
34✔
87
}
88

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

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

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

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

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

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

122
impl VisitorVTable<NullVTable> for NullVTable {
UNCOV
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> {
14✔
130
        Ok(Canonical::Null(array.clone()))
14✔
131
    }
14✔
132
}
133

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

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

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

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

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

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