Skip to content

Commit 79d3984

Browse files
authored
Feature: add spare_capacity_mut to PVectorMut (#5287)
Tracking issue: #5028 Signed-off-by: Connor Tsui <[email protected]>
1 parent cb46737 commit 79d3984

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

vortex-vector/src/primitive/generic_mut_impl.rs

Lines changed: 18 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,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)]

0 commit comments

Comments
 (0)