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 BitBuffer.
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
Source§impl Mask
impl Mask
Sourcepub fn from_indices(len: usize, indices: Vec<usize>) -> Mask
pub fn from_indices(len: usize, indices: Vec<usize>) -> Mask
Create a new Mask from a Vec<usize>.
Sourcepub fn from_excluded_indices(
len: usize,
indices: impl IntoIterator<Item = usize>,
) -> Mask
pub fn from_excluded_indices( len: usize, indices: impl IntoIterator<Item = usize>, ) -> Mask
Create a new Mask from an IntoIterator<Item = usize> of indices to be excluded.
Sourcepub fn from_slices(len: usize, vec: Vec<(usize, usize)>) -> Mask
pub fn from_slices(len: usize, vec: Vec<(usize, usize)>) -> Mask
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>,
) -> Mask
pub fn from_intersection_indices( len: usize, lhs: impl Iterator<Item = usize>, rhs: impl Iterator<Item = usize>, ) -> Mask
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 slice(&self, range: impl RangeBounds<usize>) -> Mask
pub fn slice(&self, range: impl RangeBounds<usize>) -> Mask
Slice the mask.
Sourcepub fn bit_buffer(&self) -> AllOr<&BitBuffer>
pub fn bit_buffer(&self) -> AllOr<&BitBuffer>
Return the boolean buffer representation of the mask.
Sourcepub fn to_bit_buffer(&self) -> BitBuffer
pub fn to_bit_buffer(&self) -> BitBuffer
Return a boolean buffer representation of the mask, allocating new buffers for all-true and all-false variants.
Sourcepub fn into_bit_buffer(self) -> BitBuffer
pub fn into_bit_buffer(self) -> BitBuffer
Return a boolean buffer representation of the mask, allocating new buffers for all-true and all-false variants.
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.
Sourcepub fn valid_counts_for_indices(&self, indices: &[usize]) -> Vec<usize>
pub fn valid_counts_for_indices(&self, indices: &[usize]) -> Vec<usize>
Given monotonically increasing indices in [0, n_rows], returns the
count of valid elements up to each index.
This is O(n_rows).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Mask
impl<'de> Deserialize<'de> for Mask
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Mask, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Mask, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Filter<Mask> for &NullVector
impl Filter<Mask> for &NullVector
Source§impl Filter<Mask> for &mut BitBufferMut
impl Filter<Mask> for &mut BitBufferMut
Source§impl Filter<Mask> for &mut NullVectorMut
impl Filter<Mask> for &mut NullVectorMut
Source§impl Filter<Mask> for NullVector
impl Filter<Mask> for NullVector
Source§type Output = NullVector
type Output = NullVector
Source§impl FromIterator<Mask> for Mask
impl FromIterator<Mask> for Mask
Source§impl FromIterator<Mask> for Validity
impl FromIterator<Mask> for Validity
Source§impl FromIterator<bool> for Mask
impl FromIterator<bool> for Mask
Source§impl Serialize for Mask
impl Serialize for Mask
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl<I> Take<PVector<I>> for &Maskwhere
I: UnsignedPType,
impl<I> Take<PVector<I>> for &Maskwhere
I: UnsignedPType,
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> DynArrayEq for Twhere
T: ArrayEq + 'static,
impl<T> DynArrayEq for Twhere
T: ArrayEq + 'static,
Source§impl<T> DynArrayHash for T
impl<T> DynArrayHash for T
fn dyn_array_hash(&self, state: &mut dyn Hasher, precision: Precision)
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§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 moreSource§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 moreSource§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
Source§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
Source§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.Source§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.Source§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.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SessionVar for T
impl<T> SessionVar for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.