Struct polars_arrow::array::MutableBooleanArray
source · pub struct MutableBooleanArray { /* private fields */ }
Expand description
The Arrow’s equivalent to Vec<Option<bool>>
, but with 1/16
of its size.
Converting a MutableBooleanArray
into a BooleanArray
is O(1)
.
§Implementation
This struct does not allocate a validity until one is required (i.e. push a null to it).
Implementations§
source§impl<'a> MutableBooleanArray
impl<'a> MutableBooleanArray
sourcepub fn iter(&'a self) -> ZipValidity<bool, BitmapIter<'a>, BitmapIter<'a>> ⓘ
pub fn iter(&'a self) -> ZipValidity<bool, BitmapIter<'a>, BitmapIter<'a>> ⓘ
Returns an iterator over the optional values of this MutableBooleanArray
.
sourcepub fn values_iter(&'a self) -> BitmapIter<'a> ⓘ
pub fn values_iter(&'a self) -> BitmapIter<'a> ⓘ
Returns an iterator over the values of this MutableBooleanArray
source§impl MutableBooleanArray
impl MutableBooleanArray
sourcepub fn new() -> Self
pub fn new() -> Self
Creates an new empty MutableBooleanArray
.
sourcepub fn try_new(
data_type: ArrowDataType,
values: MutableBitmap,
validity: Option<MutableBitmap>,
) -> PolarsResult<Self>
pub fn try_new( data_type: ArrowDataType, values: MutableBitmap, validity: Option<MutableBitmap>, ) -> PolarsResult<Self>
The canonical method to create a MutableBooleanArray
out of low-end APIs.
§Errors
This function errors iff:
- The validity is not
None
and its length is different fromvalues
’s length - The
data_type
’sPhysicalType
is not equal toPhysicalType::Boolean
.
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an new MutableBooleanArray
with a capacity of values.
pub fn push_value(&mut self, value: bool)
pub fn push_null(&mut self)
sourcepub fn push(&mut self, value: Option<bool>)
pub fn push(&mut self, value: Option<bool>)
Pushes a new entry to MutableBooleanArray
.
sourcepub fn pop(&mut self) -> Option<bool>
pub fn pop(&mut self) -> Option<bool>
Pop an entry from MutableBooleanArray
.
Note If the values is empty, this method will return None.
sourcepub fn extend_trusted_len_values<I>(&mut self, iterator: I)where
I: TrustedLen<Item = bool>,
pub fn extend_trusted_len_values<I>(&mut self, iterator: I)where
I: TrustedLen<Item = bool>,
Extends the MutableBooleanArray
from an iterator of values of trusted len.
This differs from extend_trusted_len
which accepts in iterator of optional values.
sourcepub unsafe fn extend_trusted_len_values_unchecked<I>(&mut self, iterator: I)
pub unsafe fn extend_trusted_len_values_unchecked<I>(&mut self, iterator: I)
Extends the MutableBooleanArray
from an iterator of values of trusted len.
This differs from extend_trusted_len_unchecked
, which accepts in iterator of optional values.
§Safety
The iterator must be trusted len.
sourcepub fn extend_trusted_len<I, P>(&mut self, iterator: I)
pub fn extend_trusted_len<I, P>(&mut self, iterator: I)
Extends the MutableBooleanArray
from an iterator of trusted len.
sourcepub unsafe fn extend_trusted_len_unchecked<I, P>(&mut self, iterator: I)
pub unsafe fn extend_trusted_len_unchecked<I, P>(&mut self, iterator: I)
Extends the MutableBooleanArray
from an iterator of trusted len.
§Safety
The iterator must be trusted len.
sourcepub fn extend_constant(&mut self, additional: usize, value: Option<bool>)
pub fn extend_constant(&mut self, additional: usize, value: Option<bool>)
Extends MutableBooleanArray
by additional values of constant value.
pub fn freeze(self) -> BooleanArray
source§impl MutableBooleanArray
impl MutableBooleanArray
Getters
sourcepub fn values(&self) -> &MutableBitmap
pub fn values(&self) -> &MutableBitmap
Returns its values.
source§impl MutableBooleanArray
impl MutableBooleanArray
Setters
source§impl MutableBooleanArray
impl MutableBooleanArray
From implementations
sourcepub fn from_trusted_len_values_iter<I: TrustedLen<Item = bool>>(
iterator: I,
) -> Self
pub fn from_trusted_len_values_iter<I: TrustedLen<Item = bool>>( iterator: I, ) -> Self
Creates a new MutableBooleanArray
from an TrustedLen
of bool
.
sourcepub unsafe fn from_trusted_len_values_iter_unchecked<I: Iterator<Item = bool>>(
iterator: I,
) -> Self
pub unsafe fn from_trusted_len_values_iter_unchecked<I: Iterator<Item = bool>>( iterator: I, ) -> Self
Creates a new MutableBooleanArray
from an TrustedLen
of bool
.
Use this over BooleanArray::from_trusted_len_iter
when the iterator is trusted len
but this crate does not mark it as such.
§Safety
The iterator must be TrustedLen
.
I.e. that size_hint().1
correctly reports its length.
sourcepub fn from_slice<P: AsRef<[bool]>>(slice: P) -> Self
pub fn from_slice<P: AsRef<[bool]>>(slice: P) -> Self
Creates a new MutableBooleanArray
from a slice of bool
.
sourcepub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Self
pub unsafe fn from_trusted_len_iter_unchecked<I, P>(iterator: I) -> Self
Creates a BooleanArray
from an iterator of trusted length.
Use this over BooleanArray::from_trusted_len_iter
when the iterator is trusted len
but this crate does not mark it as such.
§Safety
The iterator must be TrustedLen
.
I.e. that size_hint().1
correctly reports its length.
sourcepub fn from_trusted_len_iter<I, P>(iterator: I) -> Self
pub fn from_trusted_len_iter<I, P>(iterator: I) -> Self
Creates a BooleanArray
from a TrustedLen
.
sourcepub unsafe fn try_from_trusted_len_iter_unchecked<E, I, P>(
iterator: I,
) -> Result<Self, E>
pub unsafe fn try_from_trusted_len_iter_unchecked<E, I, P>( iterator: I, ) -> Result<Self, E>
Creates a BooleanArray
from an falible iterator of trusted length.
§Safety
The iterator must be TrustedLen
.
I.e. that size_hint().1
correctly reports its length.
sourcepub fn try_from_trusted_len_iter<E, I, P>(iterator: I) -> Result<Self, E>
pub fn try_from_trusted_len_iter<E, I, P>(iterator: I) -> Result<Self, E>
Creates a BooleanArray
from a TrustedLen
.
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the MutableBooleanArray
to fit its current length.
Trait Implementations§
source§impl Clone for MutableBooleanArray
impl Clone for MutableBooleanArray
source§fn clone(&self) -> MutableBooleanArray
fn clone(&self) -> MutableBooleanArray
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MutableBooleanArray
impl Debug for MutableBooleanArray
source§impl Default for MutableBooleanArray
impl Default for MutableBooleanArray
source§impl Extend<Option<bool>> for MutableBooleanArray
impl Extend<Option<bool>> for MutableBooleanArray
source§fn extend<I: IntoIterator<Item = Option<bool>>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Option<bool>>>(&mut self, iter: I)
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 From<MutableBooleanArray> for BooleanArray
impl From<MutableBooleanArray> for BooleanArray
source§fn from(other: MutableBooleanArray) -> Self
fn from(other: MutableBooleanArray) -> Self
source§impl<P: AsRef<[Option<bool>]>> From<P> for MutableBooleanArray
impl<P: AsRef<[Option<bool>]>> From<P> for MutableBooleanArray
source§fn from(slice: P) -> Self
fn from(slice: P) -> Self
Creates a new MutableBooleanArray
out of a slice of Optional bool
.
source§impl<Ptr: Borrow<Option<bool>>> FromIterator<Ptr> for MutableBooleanArray
impl<Ptr: Borrow<Option<bool>>> FromIterator<Ptr> for MutableBooleanArray
source§fn from_iter<I: IntoIterator<Item = Ptr>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = Ptr>>(iter: I) -> Self
source§impl<'a> IntoIterator for &'a MutableBooleanArray
impl<'a> IntoIterator for &'a MutableBooleanArray
§type IntoIter = ZipValidity<bool, BitmapIter<'a>, BitmapIter<'a>>
type IntoIter = ZipValidity<bool, BitmapIter<'a>, BitmapIter<'a>>
source§impl MutableArray for MutableBooleanArray
impl MutableArray for MutableBooleanArray
source§fn validity(&self) -> Option<&MutableBitmap>
fn validity(&self) -> Option<&MutableBitmap>
source§fn as_arc(&mut self) -> Arc<dyn Array>
fn as_arc(&mut self) -> Arc<dyn Array>
Array
.source§fn data_type(&self) -> &ArrowDataType
fn data_type(&self) -> &ArrowDataType
ArrowDataType
of the array.source§fn as_mut_any(&mut self) -> &mut dyn Any
fn as_mut_any(&mut self) -> &mut dyn Any
Any
, to enable dynamic casting.source§fn shrink_to_fit(&mut self)
fn shrink_to_fit(&mut self)
source§impl PartialEq for MutableBooleanArray
impl PartialEq for MutableBooleanArray
source§impl Pushable<Option<bool>> for MutableBooleanArray
impl Pushable<Option<bool>> for MutableBooleanArray
type Freeze = BooleanArray
fn reserve(&mut self, additional: usize)
fn push(&mut self, value: Option<bool>)
fn len(&self) -> usize
fn push_null(&mut self)
fn extend_constant(&mut self, additional: usize, value: Option<bool>)
fn extend_null_constant(&mut self, additional: usize)
fn freeze(self) -> Self::Freeze
fn with_capacity(capacity: usize) -> Self
source§impl Pushable<bool> for MutableBooleanArray
impl Pushable<bool> for MutableBooleanArray
type Freeze = BooleanArray
fn reserve(&mut self, additional: usize)
fn push(&mut self, value: bool)
fn len(&self) -> usize
fn push_null(&mut self)
fn extend_constant(&mut self, additional: usize, value: bool)
fn extend_null_constant(&mut self, _additional: usize)
fn freeze(self) -> Self::Freeze
fn with_capacity(capacity: usize) -> Self
source§impl TryExtend<Option<bool>> for MutableBooleanArray
impl TryExtend<Option<bool>> for MutableBooleanArray
source§fn try_extend<I: IntoIterator<Item = Option<bool>>>(
&mut self,
iter: I,
) -> PolarsResult<()>
fn try_extend<I: IntoIterator<Item = Option<bool>>>( &mut self, iter: I, ) -> PolarsResult<()>
This is infalible and is implemented for consistency with all other types
source§impl TryExtendFromSelf for MutableBooleanArray
impl TryExtendFromSelf for MutableBooleanArray
source§fn try_extend_from_self(&mut self, other: &Self) -> PolarsResult<()>
fn try_extend_from_self(&mut self, other: &Self) -> PolarsResult<()>
other
, failing only on overflow.Auto Trait Implementations§
impl Freeze for MutableBooleanArray
impl RefUnwindSafe for MutableBooleanArray
impl Send for MutableBooleanArray
impl Sync for MutableBooleanArray
impl Unpin for MutableBooleanArray
impl UnwindSafe for MutableBooleanArray
Blanket Implementations§
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<A, T, E> FromFallibleIterator<A, E> for Twhere
T: FromIterator<A>,
E: Error,
impl<A, T, E> FromFallibleIterator<A, E> for Twhere
T: FromIterator<A>,
E: Error,
fn from_fallible_iter<F>(iter: F) -> Result<T, E>where
F: FallibleIterator<E, Item = A>,
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 more