File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
vortex-vector/src/primitive Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 33
44//! Helper methods for [`PVectorMut<T>`] that mimic the behavior of [`std::vec::Vec`].
55
6+ use std:: mem:: MaybeUninit ;
7+
68use vortex_buffer:: BufferMut ;
79use vortex_dtype:: NativePType ;
810
@@ -133,6 +135,22 @@ impl<T: NativePType> PVectorMut<T> {
133135 }
134136 }
135137 }
138+
139+ /// Returns the remaining spare capacity of the vector as a slice of [`MaybeUninit<T>`].
140+ ///
141+ /// The returned slice can be used to fill the buffer with data before marking the data as
142+ /// initialized using unsafe methods like [`set_len`].
143+ ///
144+ /// Note that this only provides access to the spare capacity of the **elements** buffer.
145+ ///
146+ /// After writing to the spare capacity and calling [`set_len`], the caller must also ensure the
147+ /// validity mask is updated accordingly to maintain consistency.
148+ ///
149+ /// [`set_len`]: Self::set_len
150+ #[ inline]
151+ pub fn spare_capacity_mut ( & mut self ) -> & mut [ MaybeUninit < T > ] {
152+ self . elements . spare_capacity_mut ( )
153+ }
136154}
137155
138156#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments