Skip to content

Commit 41a4e4b

Browse files
committed
add spare_capacity_mut to PVectorMut
Signed-off-by: Connor Tsui <[email protected]>
1 parent 815a4e2 commit 41a4e4b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

vortex-vector/src/primitive/generic_mut_impl.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
//! Helper methods for [`PVectorMut<T>`] that mimic the behavior of [`std::vec::Vec`].
55
6+
use std::mem::MaybeUninit;
7+
68
use vortex_buffer::BufferMut;
79
use vortex_dtype::NativePType;
810

@@ -133,6 +135,20 @@ 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+
#[inline]
149+
pub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>] {
150+
self.elements.spare_capacity_mut()
151+
}
136152
}
137153

138154
#[cfg(test)]

0 commit comments

Comments
 (0)