pub struct BooleanArray { /* private fields */ }Expand description
A bit-packed column of booleans with an optional validity bitmap.
Implementations§
Source§impl BooleanArray
impl BooleanArray
Sourcepub fn new(values: Bitmap, validity: Option<Bitmap>) -> Result<Self>
pub fn new(values: Bitmap, validity: Option<Bitmap>) -> Result<Self>
Builds an array from a values bitmap and an optional validity bitmap.
§Errors
DataError::ValidityLengthMismatch when the two bitmaps disagree on
length.
use astrs_data::array::{Array, BooleanArray};
use astrs_data::Bitmap;
let values: Bitmap = [true, false, true].into_iter().collect();
let validity: Bitmap = [true, true, false].into_iter().collect();
let flags = BooleanArray::new(values, Some(validity))?;
assert_eq!(flags.null_count(), 1);Sourcepub fn from_values(values: impl IntoIterator<Item = bool>) -> Self
pub fn from_values(values: impl IntoIterator<Item = bool>) -> Self
Builds an array with no nulls.
Sourcepub fn from_opt_iter(values: impl IntoIterator<Item = Option<bool>>) -> Self
pub fn from_opt_iter(values: impl IntoIterator<Item = Option<bool>>) -> Self
Builds an array from optional values, null slots holding false.
Sourcepub const fn values(&self) -> &Bitmap
pub const fn values(&self) -> &Bitmap
The values bitmap, including the placeholder in every null slot.
Sourcepub fn value(&self, index: usize) -> Option<bool>
pub fn value(&self, index: usize) -> Option<bool>
The raw slot value at index, ignoring validity.
Returns None only when index is out of range.
Sourcepub fn get(&self, index: usize) -> Option<bool>
pub fn get(&self, index: usize) -> Option<bool>
The logical value at index: None when the slot is null or out of
range.
Sourcepub fn true_count(&self) -> usize
pub fn true_count(&self) -> usize
Number of non-null slots holding true.
use astrs_data::array::BooleanArray;
let flags = BooleanArray::from_opt_iter([Some(true), None, Some(true), Some(false)]);
assert_eq!(flags.true_count(), 2);
assert_eq!(flags.false_count(), 1);Sourcepub fn false_count(&self) -> usize
pub fn false_count(&self) -> usize
Number of non-null slots holding false.
Sourcepub fn slice(&self, offset: usize, len: usize) -> Self
pub fn slice(&self, offset: usize, len: usize) -> Self
A zero-copy sub-range, clamped to the array (the crate-wide slicing convention).
Sourcepub fn with_validity(&self, validity: Option<Bitmap>) -> Result<Self>
pub fn with_validity(&self, validity: Option<Bitmap>) -> Result<Self>
Returns a copy with a different validity bitmap.
§Errors
DataError::ValidityLengthMismatch when the bitmap length is wrong.
Trait Implementations§
Source§impl Array for BooleanArray
impl Array for BooleanArray
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
ArrayExt::downcast.Source§fn validity(&self) -> Option<&Bitmap>
fn validity(&self) -> Option<&Bitmap>
None when every slot is valid. Read moreSource§fn buffer_memory_size(&self) -> usize
fn buffer_memory_size(&self) -> usize
Source§fn null_count(&self) -> usize
fn null_count(&self) -> usize
Source§impl ArrayAccessor for &BooleanArray
impl ArrayAccessor for &BooleanArray
Source§impl Clone for BooleanArray
impl Clone for BooleanArray
Source§impl Debug for BooleanArray
impl Debug for BooleanArray
impl Eq for BooleanArray
Source§impl FromIterator<Option<bool>> for BooleanArray
impl FromIterator<Option<bool>> for BooleanArray
Source§impl FromIterator<bool> for BooleanArray
impl FromIterator<bool> for BooleanArray
Source§impl<'a> IntoIterator for &'a BooleanArray
impl<'a> IntoIterator for &'a BooleanArray
Auto Trait Implementations§
impl !Freeze for BooleanArray
impl RefUnwindSafe for BooleanArray
impl Send for BooleanArray
impl Sync for BooleanArray
impl Unpin for BooleanArray
impl UnsafeUnpin for BooleanArray
impl UnwindSafe for BooleanArray
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§impl<A> IntoArrayRef for Awhere
A: Array,
impl<A> IntoArrayRef for Awhere
A: Array,
Source§fn into_array_ref(self) -> ArrayRef
fn into_array_ref(self) -> ArrayRef
self into a shared, dynamically typed column.