pub struct BooleanArray {
values: BooleanBuffer,
nulls: Option<NullBuffer>,
}
Expand description
An array of boolean values
§Example: From a Vec
let arr: BooleanArray = vec![true, true, false].into();
§Example: From an optional Vec
let arr: BooleanArray = vec![Some(true), None, Some(false)].into();
§Example: From an iterator
let arr: BooleanArray = (0..5).map(|x| (x % 2 == 0).then(|| x % 3 == 0)).collect();
let values: Vec<_> = arr.iter().collect();
assert_eq!(&values, &[Some(true), None, Some(false), None, Some(false)])
§Example: Using Builder
let mut builder = BooleanBuilder::new();
builder.append_value(true);
builder.append_null();
builder.append_value(false);
let array = builder.finish();
let values: Vec<_> = array.iter().collect();
assert_eq!(&values, &[Some(true), None, Some(false)])
Fields§
§values: BooleanBuffer
§nulls: Option<NullBuffer>
Implementations§
§impl BooleanArray
impl BooleanArray
pub fn new(values: BooleanBuffer, nulls: Option<NullBuffer>) -> BooleanArray
pub fn new(values: BooleanBuffer, nulls: Option<NullBuffer>) -> BooleanArray
Create a new BooleanArray
from the provided values and nulls
§Panics
Panics if values.len() != nulls.len()
pub fn new_null(len: usize) -> BooleanArray
pub fn new_null(len: usize) -> BooleanArray
Create a new BooleanArray
with length len
consisting only of nulls
pub fn new_scalar(value: bool) -> Scalar<BooleanArray>
pub fn new_scalar(value: bool) -> Scalar<BooleanArray>
Create a new Scalar
from value
pub fn new_from_packed(
buffer: impl Into<Buffer>,
offset: usize,
len: usize,
) -> BooleanArray
pub fn new_from_packed( buffer: impl Into<Buffer>, offset: usize, len: usize, ) -> BooleanArray
Create a new BooleanArray
from a Buffer
specified by offset
and len
, the offset
and len
in bits
Logically convert each bit in Buffer
to boolean and use it to build BooleanArray
.
using this method will make the following points self-evident:
- there is no
null
in the constructedBooleanArray
; - without considering
buffer.into()
, this method is efficient because there is no need to perform pack and unpack operations on boolean;
pub fn new_from_u8(value: &[u8]) -> BooleanArray
pub fn new_from_u8(value: &[u8]) -> BooleanArray
Create a new BooleanArray
from &[u8]
This method uses new_from_packed
and constructs a Buffer
using value
, and offset is set to 0 and len is set to value.len() * 8
using this method will make the following points self-evident:
- there is no
null
in the constructedBooleanArray
; - the length of the constructed
BooleanArray
is always a multiple of 8;
pub fn slice(&self, offset: usize, length: usize) -> BooleanArray
pub fn slice(&self, offset: usize, length: usize) -> BooleanArray
Returns a zero-copy slice of this array with the indicated offset and length.
pub fn builder(capacity: usize) -> BooleanBuilder
pub fn builder(capacity: usize) -> BooleanBuilder
Returns a new boolean array builder
pub fn values(&self) -> &BooleanBuffer
pub fn values(&self) -> &BooleanBuffer
Returns the underlying BooleanBuffer
holding all the values of this array
pub fn true_count(&self) -> usize
pub fn true_count(&self) -> usize
Returns the number of non null, true values within this array
pub fn false_count(&self) -> usize
pub fn false_count(&self) -> usize
Returns the number of non null, false values within this array
pub 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()
pub 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
pub 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()
pub fn from_unary<T, F>(left: T, op: F) -> BooleanArray
pub fn from_unary<T, F>(left: T, op: F) -> BooleanArray
Create a BooleanArray
by evaluating the operation for
each element of the provided array
let array = Int32Array::from(vec![1, 2, 3, 4, 5]);
let r = BooleanArray::from_unary(&array, |x| x > 2);
assert_eq!(&r, &BooleanArray::from(vec![false, false, true, true, true]));
pub fn from_binary<T, S, F>(left: T, right: S, op: F) -> BooleanArraywhere
T: ArrayAccessor,
S: ArrayAccessor,
F: FnMut(<T as ArrayAccessor>::Item, <S as ArrayAccessor>::Item) -> bool,
pub fn from_binary<T, S, F>(left: T, right: S, op: F) -> BooleanArraywhere
T: ArrayAccessor,
S: ArrayAccessor,
F: FnMut(<T as ArrayAccessor>::Item, <S as ArrayAccessor>::Item) -> bool,
Create a BooleanArray
by evaluating the binary operation for
each element of the provided arrays
let a = Int32Array::from(vec![1, 2, 3, 4, 5]);
let b = Int32Array::from(vec![1, 2, 0, 2, 5]);
let r = BooleanArray::from_binary(&a, &b, |a, b| a == b);
assert_eq!(&r, &BooleanArray::from(vec![true, true, false, false, true]));
§Panics
This function panics if left and right are not the same length
pub fn into_parts(self) -> (BooleanBuffer, Option<NullBuffer>)
pub fn into_parts(self) -> (BooleanBuffer, Option<NullBuffer>)
Deconstruct this array into its constituent parts
§impl<'a> BooleanArray
impl<'a> BooleanArray
pub fn iter(&'a self) -> ArrayIter<&'a BooleanArray> ⓘ
pub fn iter(&'a self) -> ArrayIter<&'a BooleanArray> ⓘ
constructs a new iterator
Trait Implementations§
§impl ArrayAccessor for &BooleanArray
impl ArrayAccessor for &BooleanArray
§fn value(&self, index: usize) -> <&BooleanArray as ArrayAccessor>::Item
fn value(&self, index: usize) -> <&BooleanArray as ArrayAccessor>::Item
i
Read more§unsafe fn value_unchecked(
&self,
index: usize,
) -> <&BooleanArray as ArrayAccessor>::Item
unsafe fn value_unchecked( &self, index: usize, ) -> <&BooleanArray as ArrayAccessor>::Item
i
Read more§impl Array for BooleanArray
impl Array for BooleanArray
§fn slice(&self, offset: usize, length: usize) -> Arc<dyn Array>
fn slice(&self, offset: usize, length: usize) -> Arc<dyn Array>
§fn shrink_to_fit(&mut self)
fn shrink_to_fit(&mut self)
§fn offset(&self) -> usize
fn offset(&self) -> usize
0
. Read more§fn nulls(&self) -> Option<&NullBuffer>
fn nulls(&self) -> Option<&NullBuffer>
§fn logical_null_count(&self) -> usize
fn logical_null_count(&self) -> usize
§fn get_buffer_memory_size(&self) -> usize
fn get_buffer_memory_size(&self) -> usize
§fn get_array_memory_size(&self) -> usize
fn get_array_memory_size(&self) -> usize
get_buffer_memory_size()
and
includes the overhead of the data structures that contain the pointers to the various buffers.§fn logical_nulls(&self) -> Option<NullBuffer>
fn logical_nulls(&self) -> Option<NullBuffer>
NullBuffer
that represents the logical
null values of this array, if any. Read more§fn null_count(&self) -> usize
fn null_count(&self) -> usize
§fn is_nullable(&self) -> bool
fn is_nullable(&self) -> bool
false
if the array is guaranteed to not contain any logical nulls Read more§impl Clone for BooleanArray
impl Clone for BooleanArray
§fn clone(&self) -> BooleanArray
fn clone(&self) -> BooleanArray
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for BooleanArray
impl Debug for BooleanArray
§impl From<ArrayData> for BooleanArray
impl From<ArrayData> for BooleanArray
§fn from(data: ArrayData) -> BooleanArray
fn from(data: ArrayData) -> BooleanArray
§impl From<BooleanArray> for ArrayData
impl From<BooleanArray> for ArrayData
§fn from(array: BooleanArray) -> ArrayData
fn from(array: BooleanArray) -> ArrayData
§impl From<BooleanArray> for BooleanArray
impl From<BooleanArray> for BooleanArray
arrow2 -> arrow
§fn from(array: BooleanArray) -> BooleanArray
fn from(array: BooleanArray) -> BooleanArray
§impl From<BooleanBuffer> for BooleanArray
impl From<BooleanBuffer> for BooleanArray
§fn from(values: BooleanBuffer) -> BooleanArray
fn from(values: BooleanBuffer) -> BooleanArray
§impl From<Vec<bool>> for BooleanArray
impl From<Vec<bool>> for BooleanArray
§fn from(data: Vec<bool>) -> BooleanArray
fn from(data: Vec<bool>) -> BooleanArray
§impl<Ptr> FromIterator<Ptr> for BooleanArray
impl<Ptr> FromIterator<Ptr> for BooleanArray
§fn from_iter<I>(iter: I) -> BooleanArraywhere
I: IntoIterator<Item = Ptr>,
fn from_iter<I>(iter: I) -> BooleanArraywhere
I: IntoIterator<Item = Ptr>,
§impl<'a> IntoIterator for &'a BooleanArray
impl<'a> IntoIterator for &'a BooleanArray
§type IntoIter = ArrayIter<&'a BooleanArray>
type IntoIter = ArrayIter<&'a BooleanArray>
§fn into_iter(self) -> <&'a BooleanArray as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a BooleanArray as IntoIterator>::IntoIter
§impl PartialEq for BooleanArray
impl PartialEq for BooleanArray
§fn eq(&self, other: &BooleanArray) -> bool
fn eq(&self, other: &BooleanArray) -> bool
self
and other
values to be equal, and is used
by ==
.Auto Trait Implementations§
impl Freeze for BooleanArray
impl RefUnwindSafe for BooleanArray
impl Send for BooleanArray
impl Sync for BooleanArray
impl Unpin 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> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
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
)§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§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 more§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 more§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
§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
§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.§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.§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.§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<T> Tap for T
impl<T> Tap for T
§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 more§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 more§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 more§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 more§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 more§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 more§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.§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.§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.§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.§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.§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.§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.