33
44//! Definition and implementation of [`NullVectorMut`].
55
6+ use vortex_mask:: MaskMut ;
7+
68use crate :: VectorMutOps ;
79use crate :: null:: NullVector ;
810
@@ -12,16 +14,22 @@ use crate::null::NullVector;
1214/// single `length` counter.
1315///
1416/// The immutable equivalent of this type is [`NullVector`].
15- #[ derive( Debug , Clone , Copy ) ]
17+ #[ derive( Debug , Clone ) ]
1618pub struct NullVectorMut {
1719 /// The total number of nulls.
1820 pub ( super ) len : usize ,
21+ /// The validity mask. We only store this in order to implement the
22+ /// [`validity()`](Self::validity) method.
23+ pub ( super ) validity : MaskMut ,
1924}
2025
2126impl NullVectorMut {
2227 /// Creates a new mutable vector of nulls with the given length.
2328 pub fn new ( len : usize ) -> Self {
24- Self { len }
29+ Self {
30+ len,
31+ validity : MaskMut :: new_false ( len) ,
32+ }
2533 }
2634}
2735
@@ -32,6 +40,10 @@ impl VectorMutOps for NullVectorMut {
3240 self . len
3341 }
3442
43+ fn validity ( & self ) -> & MaskMut {
44+ & self . validity
45+ }
46+
3547 fn capacity ( & self ) -> usize {
3648 usize:: MAX
3749 }
@@ -62,7 +74,10 @@ impl VectorMutOps for NullVectorMut {
6274
6375 let new_len = self . len . saturating_sub ( at) ;
6476 self . len = std:: cmp:: min ( self . len , at) ;
65- NullVectorMut { len : new_len }
77+ NullVectorMut {
78+ len : new_len,
79+ validity : MaskMut :: new_false ( new_len) ,
80+ }
6681 }
6782
6883 fn unsplit ( & mut self , other : Self ) {
0 commit comments