Struct arrow::array::BooleanArray
source · pub struct BooleanArray { /* private fields */ }
Expand description
Array of bools
Example
use arrow_array::{Array, BooleanArray};
let arr = BooleanArray::from(vec![Some(false), Some(true), None, Some(true)]);
assert_eq!(4, arr.len());
assert_eq!(1, arr.null_count());
assert!(arr.is_valid(0));
assert!(!arr.is_null(0));
assert_eq!(false, arr.value(0));
assert!(arr.is_valid(1));
assert!(!arr.is_null(1));
assert_eq!(true, arr.value(1));
assert!(!arr.is_valid(2));
assert!(arr.is_null(2));
assert!(arr.is_valid(3));
assert!(!arr.is_null(3));
assert_eq!(true, arr.value(3));
Using from_iter
use arrow_array::{Array, BooleanArray};
let v = vec![Some(false), Some(true), Some(false), Some(true)];
let arr = v.into_iter().collect::<BooleanArray>();
assert_eq!(4, arr.len());
assert_eq!(0, arr.offset());
assert_eq!(0, arr.null_count());
assert!(arr.is_valid(0));
assert_eq!(false, arr.value(0));
assert!(arr.is_valid(1));
assert_eq!(true, arr.value(1));
assert!(arr.is_valid(2));
assert_eq!(false, arr.value(2));
assert!(arr.is_valid(3));
assert_eq!(true, arr.value(3));
Implementations§
source§impl BooleanArray
impl BooleanArray
sourcepub fn builder(capacity: usize) -> BooleanBuilder
pub fn builder(capacity: usize) -> BooleanBuilder
Returns a new boolean array builder
sourcepub fn values(&self) -> &Buffer
pub fn values(&self) -> &Buffer
Returns a Buffer
holding all the values of this array.
Note this doesn’t take the offset of this array into account.
sourcepub fn true_count(&self) -> usize
pub fn true_count(&self) -> usize
Returns the number of non null, true values within this array
sourcepub fn false_count(&self) -> usize
pub fn false_count(&self) -> usize
Returns the number of non null, false values within this array
sourcepub unsafe fn value_unchecked(&self, i: usize) -> bool
pub unsafe fn value_unchecked(&self, i: usize) -> bool
Returns the boolean value at index i
.
Safety
This doesn’t check bounds, the caller must ensure that index < self.len()
sourcepub fn take_iter<'a>(
&'a self,
indexes: impl Iterator<Item = Option<usize>> + 'a
) -> impl Iterator<Item = Option<bool>> + 'a
pub fn take_iter<'a>(
&'a self,
indexes: impl Iterator<Item = Option<usize>> + 'a
) -> impl Iterator<Item = Option<bool>> + 'a
Returns an iterator that returns the values of array.value(i)
for an iterator with each element i
sourcepub unsafe fn take_iter_unchecked<'a>(
&'a self,
indexes: impl Iterator<Item = Option<usize>> + 'a
) -> impl Iterator<Item = Option<bool>> + 'a
pub unsafe fn take_iter_unchecked<'a>(
&'a self,
indexes: impl Iterator<Item = Option<usize>> + 'a
) -> impl Iterator<Item = Option<bool>> + 'a
Returns an iterator that returns the values of array.value(i)
for an iterator with each element i
Safety
caller must ensure that the offsets in the iterator are less than the array len()
source§impl<'a> BooleanArray
impl<'a> BooleanArray
sourcepub fn iter(&'a self) -> ArrayIter<&'a BooleanArray> ⓘ
pub fn iter(&'a self) -> ArrayIter<&'a BooleanArray> ⓘ
constructs a new iterator
Trait Implementations§
source§impl Array for BooleanArray
impl Array for BooleanArray
source§fn data_ref(&self) -> &ArrayData
fn data_ref(&self) -> &ArrayData
Returns a reference-counted pointer to the underlying data of this array.
source§fn slice(&self, offset: usize, length: usize) -> Arc<dyn Array + 'static>
fn slice(&self, offset: usize, length: usize) -> Arc<dyn Array + 'static>
Returns a zero-copy slice of this array with the indicated offset and length. Read more
source§fn offset(&self) -> usize
fn offset(&self) -> usize
Returns the offset into the underlying data used by this array(-slice).
Note that the underlying data can be shared by many arrays.
This defaults to
0
. Read moresource§fn is_null(&self, index: usize) -> bool
fn is_null(&self, index: usize) -> bool
Returns whether the element at
index
is null.
When using this function on a slice, the index is relative to the slice. Read moresource§fn is_valid(&self, index: usize) -> bool
fn is_valid(&self, index: usize) -> bool
Returns whether the element at
index
is not null.
When using this function on a slice, the index is relative to the slice. Read moresource§fn null_count(&self) -> usize
fn null_count(&self) -> usize
Returns the total number of null values in this array. Read more
source§fn get_buffer_memory_size(&self) -> usize
fn get_buffer_memory_size(&self) -> usize
Returns the total number of bytes of memory pointed to by this array.
The buffers store bytes in the Arrow memory format, and include the data as well as the validity map. Read more
source§fn get_array_memory_size(&self) -> usize
fn get_array_memory_size(&self) -> usize
Returns the total number of bytes of memory occupied physically by this array.
This value will always be greater than returned by
get_buffer_memory_size()
and
includes the overhead of the data structures that contain the pointers to the various buffers. Read moresource§impl<'a> ArrayAccessor for &'a BooleanArray
impl<'a> ArrayAccessor for &'a BooleanArray
source§fn value(&self, index: usize) -> <&'a BooleanArray as ArrayAccessor>::Item
fn value(&self, index: usize) -> <&'a BooleanArray as ArrayAccessor>::Item
Returns the element at index
i
Read moresource§unsafe fn value_unchecked(
&self,
index: usize
) -> <&'a BooleanArray as ArrayAccessor>::Item
unsafe fn value_unchecked(
&self,
index: usize
) -> <&'a BooleanArray as ArrayAccessor>::Item
Returns the element at index
i
Read moresource§impl Clone for BooleanArray
impl Clone for BooleanArray
source§fn clone(&self) -> BooleanArray
fn clone(&self) -> BooleanArray
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for BooleanArray
impl Debug for BooleanArray
source§impl From<ArrayData> for BooleanArray
impl From<ArrayData> for BooleanArray
source§fn from(data: ArrayData) -> BooleanArray
fn from(data: ArrayData) -> BooleanArray
Converts to this type from the input type.
source§impl From<BooleanArray> for ArrayData
impl From<BooleanArray> for ArrayData
source§fn from(array: BooleanArray) -> ArrayData
fn from(array: BooleanArray) -> ArrayData
Converts to this type from the input type.
source§impl<Ptr> FromIterator<Ptr> for BooleanArraywhere
Ptr: Borrow<Option<bool>>,
impl<Ptr> FromIterator<Ptr> for BooleanArraywhere
Ptr: Borrow<Option<bool>>,
source§fn from_iter<I>(iter: I) -> BooleanArraywhere
I: IntoIterator<Item = Ptr>,
fn from_iter<I>(iter: I) -> BooleanArraywhere
I: IntoIterator<Item = Ptr>,
Creates a value from an iterator. Read more
source§impl<'a> IntoIterator for &'a BooleanArray
impl<'a> IntoIterator for &'a BooleanArray
§type IntoIter = ArrayIter<&'a BooleanArray>
type IntoIter = ArrayIter<&'a BooleanArray>
Which kind of iterator are we turning this into?
source§fn into_iter(self) -> <&'a BooleanArray as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a BooleanArray as IntoIterator>::IntoIter
Creates an iterator from a value. Read more