pub enum Mask {
AllTrue(usize),
AllFalse(usize),
Values(Arc<MaskValues>),
}Expand description
Represents a set of sorted unique positive integers.
A Mask can be constructed from various representations, and converted to various
others. Internally, these are cached.
Variants§
AllTrue(usize)
All values are included.
AllFalse(usize)
No values are included.
Values(Arc<MaskValues>)
Some values are included, represented as a BooleanBuffer.
Implementations§
Source§impl Mask
impl Mask
Sourcepub fn intersect_by_rank(&self, mask: &Mask) -> Mask
pub fn intersect_by_rank(&self, mask: &Mask) -> Mask
Take the intersection of the mask with the set of true values in self.
We are more interested in low selectivity self (as indices) with a boolean buffer mask,
so we don’t optimize for other cases, yet.
Note: we might be able to accelerate this function on x86 with BMI, see: https://www.microsoft.com/en-us/research/uploads/prod/2023/06/parquet-select-sigmod23.pdf
§Examples
Keep the third and fifth set values from mask m1:
use vortex_mask::Mask;
let m1 = Mask::from_iter([true, false, false, true, true, true, false, true]);
let m2 = Mask::from_iter([false, false, true, false, true]);
assert_eq!(
m1.intersect_by_rank(&m2),
Mask::from_iter([false, false, false, false, true, false, false, true])
);Source§impl Mask
impl Mask
Sourcepub fn iter_bools<F, T>(&self, f: F) -> T
pub fn iter_bools<F, T>(&self, f: F) -> T
Provides a closure with an iterator over the boolean values of the mask.
This allows us to provide different implementations of the iterator based on the underlying representation of the mask, while avoiding a heap allocation to return a boxed iterator.
Note that bool iteration might not be the fastest way to achieve whatever is it you’re trying to do!
Source§impl Mask
impl Mask
Sourcepub fn from_buffer(buffer: BooleanBuffer) -> Self
pub fn from_buffer(buffer: BooleanBuffer) -> Self
Create a new Mask from a BooleanBuffer.
Sourcepub fn from_indices(len: usize, indices: Vec<usize>) -> Self
pub fn from_indices(len: usize, indices: Vec<usize>) -> Self
Create a new Mask from a Vec<usize>.
Sourcepub fn from_excluded_indices(
len: usize,
indices: impl IntoIterator<Item = usize>,
) -> Self
pub fn from_excluded_indices( len: usize, indices: impl IntoIterator<Item = usize>, ) -> Self
Create a new Mask from an [IntoIterator<Item = usize>] of indices to be excluded.
Sourcepub fn from_slices(len: usize, vec: Vec<(usize, usize)>) -> Self
pub fn from_slices(len: usize, vec: Vec<(usize, usize)>) -> Self
Create a new Mask from a [Vec<(usize, usize)>] where each range
represents a contiguous range of true values.
Sourcepub fn from_intersection_indices(
len: usize,
lhs: impl Iterator<Item = usize>,
rhs: impl Iterator<Item = usize>,
) -> Self
pub fn from_intersection_indices( len: usize, lhs: impl Iterator<Item = usize>, rhs: impl Iterator<Item = usize>, ) -> Self
Create a new Mask from the intersection of two indices slices.
Sourcepub fn true_count(&self) -> usize
pub fn true_count(&self) -> usize
Get the true count of the mask.
Sourcepub fn false_count(&self) -> usize
pub fn false_count(&self) -> usize
Get the false count of the mask.
Sourcepub fn boolean_buffer(&self) -> AllOr<&BooleanBuffer>
pub fn boolean_buffer(&self) -> AllOr<&BooleanBuffer>
Return the boolean buffer representation of the mask.
Sourcepub fn to_boolean_buffer(&self) -> BooleanBuffer
pub fn to_boolean_buffer(&self) -> BooleanBuffer
Return a boolean buffer representation of the mask, allocating new buffers for all-true and all-false variants.
Sourcepub fn to_null_buffer(&self) -> Option<NullBuffer>
pub fn to_null_buffer(&self) -> Option<NullBuffer>
Returns an Arrow null buffer representation of the mask.
Sourcepub fn threshold_iter(&self, threshold: f64) -> AllOr<MaskIter<'_>>
pub fn threshold_iter(&self, threshold: f64) -> AllOr<MaskIter<'_>>
Return an iterator over either indices or slices of the mask based on a density threshold.
Sourcepub fn values(&self) -> Option<&MaskValues>
pub fn values(&self) -> Option<&MaskValues>
Return MaskValues if the mask is not all true or all false.
Trait Implementations§
Source§impl From<BooleanBuffer> for Mask
impl From<BooleanBuffer> for Mask
Source§fn from(value: BooleanBuffer) -> Self
fn from(value: BooleanBuffer) -> Self
Source§impl FromIterator<Mask> for Mask
impl FromIterator<Mask> for Mask
Source§impl FromIterator<bool> for Mask
impl FromIterator<bool> for Mask
impl Eq for Mask
Auto Trait Implementations§
impl Freeze for Mask
impl RefUnwindSafe for Mask
impl Send for Mask
impl Sync for Mask
impl Unpin for Mask
impl UnwindSafe for Mask
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<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