pub struct PVectorMut<T> { /* private fields */ }Expand description
A mutable vector of generic primitive values.
T is expected to be bound by NativePType, which templates an internal BufferMut<T>
that stores the elements of the vector.
Implementations§
Source§impl<T> PVectorMut<T>
impl<T> PVectorMut<T>
Sourcepub fn new(elements: BufferMut<T>, validity: MaskMut) -> Self
pub fn new(elements: BufferMut<T>, validity: MaskMut) -> Self
Creates a new PVectorMut<T> from the given elements buffer and validity mask.
§Panics
Panics if the length of the validity mask does not match the length of the elements buffer.
Sourcepub fn try_new(elements: BufferMut<T>, validity: MaskMut) -> VortexResult<Self>
pub fn try_new(elements: BufferMut<T>, validity: MaskMut) -> VortexResult<Self>
Tries to create a new PVectorMut<T> from the given elements buffer and validity mask.
§Errors
Returns an error if the length of the validity mask does not match the length of the elements buffer.
Sourcepub unsafe fn new_unchecked(elements: BufferMut<T>, validity: MaskMut) -> Self
pub unsafe fn new_unchecked(elements: BufferMut<T>, validity: MaskMut) -> Self
Creates a new PVectorMut<T> from the given elements buffer and validity mask without
validation.
§Safety
The caller must ensure that the validity mask has the same length as the elements buffer.
Ideally, they are taken from into_parts, mutated in a way that doesn’t re-allocate, and
then passed back to this function.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new mutable primitive vector with the given capacity.
Sourcepub unsafe fn set_len(&mut self, new_len: usize)
pub unsafe fn set_len(&mut self, new_len: usize)
Set the length of the vector.
§Safety
new_lenmust be less than or equal tocapacity().- The elements at
old_len..new_lenmust be initialized.
Sourcepub unsafe fn elements_mut(&mut self) -> &mut BufferMut<T>
pub unsafe fn elements_mut(&mut self) -> &mut BufferMut<T>
Returns a mutable reference to the elements buffer.
§Safety
The caller must ensure that any mutations to the elements do not violate the invariants of the vector (e.g., the length must remain consistent with the elements buffer).
Sourcepub unsafe fn validity_mut(&mut self) -> &mut MaskMut
pub unsafe fn validity_mut(&mut self) -> &mut MaskMut
Returns a mutable reference to the validity mask.
§Safety
The caller must ensure that any mutations to the validity mask do not violate the invariants of the vector (e.g., the length must remain consistent with the elements buffer).
Sourcepub fn into_parts(self) -> (BufferMut<T>, MaskMut)
pub fn into_parts(self) -> (BufferMut<T>, MaskMut)
Decomposes the primitive vector into its constituent parts (buffer and validity).
Sourcepub fn append_values(&mut self, value: T, n: usize)where
T: Copy,
pub fn append_values(&mut self, value: T, n: usize)where
T: Copy,
Append n values to the vector.
Source§impl<T: NativePType> PVectorMut<T>
Point operations for PVectorMut.
impl<T: NativePType> PVectorMut<T>
Point operations for PVectorMut.
Sourcepub fn get(&self, index: usize) -> Option<T>
pub fn get(&self, index: usize) -> Option<T>
Gets a nullable element at the given index, panicking on out-of-bounds.
If the element at the given index is null, returns None. Otherwise, returns Some(x),
where x: T.
Note that this get method is different from the standard library slice::get, which
returns None if the index is out of bounds. This method will panic if the index is out of
bounds, and return None if the elements is null.
§Panics
Panics if the index is out of bounds.
Sourcepub fn push(&mut self, value: T)
pub fn push(&mut self, value: T)
Pushes an element to the back of the vector.
The element is treated as non-null.
Sourcepub unsafe fn push_unchecked(&mut self, value: T)
pub unsafe fn push_unchecked(&mut self, value: T)
Pushes an element without bounds checking.
The element is treated as non-null.
§Safety
The caller must ensure that there is sufficient capacity in both elements and validity buffers.
Source§impl<T: NativePType> PVectorMut<T>
Batch operations for PVectorMut.
impl<T: NativePType> PVectorMut<T>
Batch operations for PVectorMut.
Sourcepub fn elements(&self) -> &BufferMut<T>
pub fn elements(&self) -> &BufferMut<T>
Returns the internal BufferMut of the PVectorMut.
Note that the internal buffer may hold garbage data in place of nulls. That information is
tracked by the validity().
Sourcepub fn resize(&mut self, new_len: usize, value: Option<T>)
pub fn resize(&mut self, new_len: usize, value: Option<T>)
Resizes the Vec in-place so that len is equal to new_len.
If new_len is greater than len, the Vec is extended by the difference, with each
additional slot filled with value, where None represent a null.
If new_len is less than len, the Vec is simply truncated.
Trait Implementations§
Source§impl<T: NativePType> AsMut<[T]> for PVectorMut<T>
impl<T: NativePType> AsMut<[T]> for PVectorMut<T>
Source§fn as_mut(&mut self) -> &mut [T]
fn as_mut(&mut self) -> &mut [T]
Returns a mutable slice over the internal mutable buffer with elements of type T.
Note that this slice may contain garbage data where the validity() mask from the frozen
PVector type states that an element is invalid.
The caller should check the frozen validity() before performing any operations.
Source§impl<T: NativePType> AsRef<[T]> for PVectorMut<T>
impl<T: NativePType> AsRef<[T]> for PVectorMut<T>
Source§fn as_ref(&self) -> &[T]
fn as_ref(&self) -> &[T]
Returns an immutable slice over the internal mutable buffer with elements of type T.
Note that this slice may contain garbage data where the validity() mask from the frozen
PVector type states that an element is invalid.
The caller should check the frozen validity() before performing any operations.
Source§impl<T: Clone> Clone for PVectorMut<T>
impl<T: Clone> Clone for PVectorMut<T>
Source§fn clone(&self) -> PVectorMut<T>
fn clone(&self) -> PVectorMut<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for PVectorMut<T>
impl<T: Debug> Debug for PVectorMut<T>
Source§impl<T: NativePType> Extend<Option<T>> for PVectorMut<T>
impl<T: NativePType> Extend<Option<T>> for PVectorMut<T>
Source§fn extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Option<T>>>(&mut self, iter: I)
Extends the vector from an iterator of optional values.
None values will be marked as null in the validity mask.
§Examples
use vortex_vector::primitive::PVectorMut;
use vortex_vector::{VectorMutOps, VectorOps};
let mut vec = PVectorMut::from_iter([Some(1i32), None]);
vec.extend([Some(3), None, Some(5)]);
assert_eq!(vec.len(), 5);
let frozen = vec.freeze();
assert_eq!(frozen.validity().true_count(), 3); // Only 3 non-null values.Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<T: NativePType> Extend<T> for PVectorMut<T>
impl<T: NativePType> Extend<T> for PVectorMut<T>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
Extends the vector from an iterator of values.
All values from the iterator will be marked as non-null in the validity mask.
Internally, this uses the Extend<T> trait implementation.
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<T: NativePType> From<PVectorMut<T>> for PrimitiveVectorMut
impl<T: NativePType> From<PVectorMut<T>> for PrimitiveVectorMut
Source§fn from(v: PVectorMut<T>) -> Self
fn from(v: PVectorMut<T>) -> Self
Source§impl<T: NativePType> From<PVectorMut<T>> for VectorMut
impl<T: NativePType> From<PVectorMut<T>> for VectorMut
Source§fn from(val: PVectorMut<T>) -> Self
fn from(val: PVectorMut<T>) -> Self
Source§impl<T: NativePType> FromIterator<Option<T>> for PVectorMut<T>
impl<T: NativePType> FromIterator<Option<T>> for PVectorMut<T>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = Option<T>>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = Option<T>>,
Creates a new PVectorMut<T> from an iterator of Option<T> values.
None values will be marked as invalid in the validity mask.
Internally, this uses the Extend<Option<T>> trait implementation.
Source§impl<T: NativePType> FromIterator<T> for PVectorMut<T>
impl<T: NativePType> FromIterator<T> for PVectorMut<T>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
Creates a new PVectorMut<T> from an iterator of T values.
All values will be treated as non-null.
§Examples
use vortex_vector::primitive::PVectorMut;
use vortex_vector::VectorMutOps;
let mut vec = PVectorMut::from_iter([1i32, 2, 3, 4]);
assert_eq!(vec.len(), 4);Source§impl<T: NativePType> IntoIterator for PVectorMut<T>
impl<T: NativePType> IntoIterator for PVectorMut<T>
Source§fn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
Converts the mutable vector into an iterator over Option<T> values.
This method consumes the PVectorMut<T> and returns an iterator that yields None for
null values and Some(value) for valid values.
§Examples
use vortex_vector::primitive::PVectorMut;
let vec = PVectorMut::<i32>::from_iter([Some(1), None, Some(3), Some(4)]);
let collected: Vec<_> = vec.into_iter().collect();
assert_eq!(collected, vec![Some(1), None, Some(3), Some(4)]);Source§impl<T: NativePType> VectorMutOps for PVectorMut<T>
impl<T: NativePType> VectorMutOps for PVectorMut<T>
Source§fn extend_from_vector(&mut self, other: &PVector<T>)
fn extend_from_vector(&mut self, other: &PVector<T>)
Extends the vector by appending elements from another vector.
Source§fn len(&self) -> usize
fn len(&self) -> usize
Source§fn validity(&self) -> &MaskMut
fn validity(&self) -> &MaskMut
true represents a valid element and
false represents a null element. Read moreSource§fn capacity(&self) -> usize
fn capacity(&self) -> usize
Source§fn reserve(&mut self, additional: usize)
fn reserve(&mut self, additional: usize)
additional more elements to be inserted in the given
vector. Read moreSource§fn truncate(&mut self, len: usize)
fn truncate(&mut self, len: usize)
Source§fn append_nulls(&mut self, n: usize)
fn append_nulls(&mut self, n: usize)
n null elements to the vector. Read moreSource§fn split_off(&mut self, at: usize) -> Self
fn split_off(&mut self, at: usize) -> Self
Auto Trait Implementations§
impl<T> Freeze for PVectorMut<T>
impl<T> RefUnwindSafe for PVectorMut<T>where
T: RefUnwindSafe,
impl<T> Send for PVectorMut<T>where
T: Send,
impl<T> Sync for PVectorMut<T>where
T: Sync,
impl<T> Unpin for PVectorMut<T>where
T: Unpin,
impl<T> UnwindSafe for PVectorMut<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<A, T> AsBits<T> for A
impl<A, T> AsBits<T> for A
Source§impl<A, T> AsMutBits<T> for A
impl<A, T> AsMutBits<T> for A
Source§fn as_mut_bits<O>(&mut self) -> &mut BitSlice<T, O> ⓘwhere
O: BitOrder,
fn as_mut_bits<O>(&mut self) -> &mut BitSlice<T, O> ⓘwhere
O: BitOrder,
self as a mutable bit-slice region with the O ordering.Source§fn try_as_mut_bits<O>(&mut self) -> Result<&mut BitSlice<T, O>, BitSpanError<T>>where
O: BitOrder,
fn try_as_mut_bits<O>(&mut self) -> Result<&mut BitSlice<T, O>, BitSpanError<T>>where
O: BitOrder,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.