File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
vortex-vector/src/primitive Expand file tree Collapse file tree 1 file changed +20
-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
@@ -131,6 +133,24 @@ impl<T: NativePType> PVectorMut<T> {
131133 }
132134 }
133135 }
136+
137+ /// Returns the remaining spare capacity of the vector as a slice of [`MaybeUninit<T>`].
138+ ///
139+ /// The returned slice can be used to fill the buffer with data before marking the data as
140+ /// initialized using unsafe methods like [`set_len`].
141+ ///
142+ /// # Safety
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 unsafe fn spare_capacity_mut ( & mut self ) -> & mut [ MaybeUninit < T > ] {
152+ self . elements . spare_capacity_mut ( )
153+ }
134154}
135155
136156#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments