Skip to main content

BitmaskV

Struct BitmaskV 

Source
pub struct BitmaskV<'a> {
    pub bitmask: &'a Bitmask,
    pub offset: usize,
    /* private fields */
}
Expand description

§BitmaskView

Zero-copy, bounds-checked window over a Bitmask.

§Fields

  • bitmask: borrowed reference to the backing Bitmask.
  • offset: start bit position in the parent mask.
  • len: number of bits in the view.

§Behaviour

  • All indexing is relative to the view’s start.
  • All accesses are in-bounds (panics if violated).
  • No allocation or buffer copying occurs when creating or slicing views.

§Example

use minarrow::Bitmask;
use minarrow::BitmaskV;

let mask = Bitmask::from_bools(&[true, false, true, true, false]);
let view = BitmaskV::new(&mask, 1, 3); // window: false, true, true

assert_eq!(view.len(), 3);
assert!(!view.get(0));
assert!(view.get(1));
assert!(view.get(2));

Fields§

§bitmask: &'a Bitmask

The outer bitmask that this view is derived from - we retain a reference to it. Importantly, this is the full bitmask - not the view, and thus should not be accessed as though it were the view subset.

§offset: usize

The index offset from 0 that for where this view starts from the outer bitmask

Implementations§

Source§

impl<'a> BitmaskV<'a>

Source

pub fn new(bitmask: &'a Bitmask, offset: usize, len: usize) -> Self

Construct a view over bitmask[offset..offset+len).

Source

pub fn len(&self) -> usize

Returns the length (number of bits) in the view.

Source

pub fn is_empty(&self) -> bool

Returns true if the view is empty.

Source

pub fn get(&self, i: usize) -> bool

Returns the value at logical index i within the view.

Source

pub unsafe fn get_unchecked(&self, i: usize) -> bool

Returns the value at logical index i within the view, skipping the bounds check.

Element-wise kernels read a flagged null_mask (valid) bit per row, so the checked get costs a comparison in the innermost loop. This is the unchecked counterpart for loops that have already established i < len.

§Safety

i must be less than the view’s length.

Source

pub fn as_bytes_window(&self) -> (&[u8], usize, usize)

Returns a slice of the bitmask’s bytes Due to the booleans being bitpacked in a u8, the slice retains:
Pos 0: Buffer: The bitpacked u8 buffer.
Pos 1: Offset: Bit offset indicating where it starts in that byte.
Pos 2: Length: Logical length in bits of the slice

Source

pub fn to_bitmask(&self) -> Bitmask

Returns an owned Bitmask for the window.

If the view covers the entire backing bitmask, returns a clone of the underlying Bitmask (cheap for Shared storage; a byte memcpy for Owned storage). Otherwise falls back to bit-by-bit slice_clone, which has to honour bit alignment across the window boundary.

Source

pub fn iter_set(&self) -> impl Iterator<Item = usize> + '_

Returns an iterator over all set bits (indices relative to the window).

The scan walks the backing mask one 64-bit word at a time from the window’s bit offset, so a word with no set bits costs a single comparison and each set bit is located through a trailing-zeros count.

Source

pub fn iter_cleared(&self) -> impl Iterator<Item = usize> + '_

Returns an iterator over all cleared bits (indices relative to the window).

The scan walks the backing mask one 64-bit word at a time from the window’s bit offset, so a fully valid word costs a single comparison and each null is located through a trailing-zeros count.

Source

pub fn count_ones(&self) -> usize

Counts number of set bits in the view.

Source

pub fn count_zeros(&self) -> usize

Counts number of cleared bits in the view.

Source

pub fn all_set(&self) -> bool

Returns true if all bits in the view are set.

Source

pub fn all_unset(&self) -> bool

Returns true if all bits in the view are cleared.

Source

pub fn has_cleared(&self) -> bool

Returns true if any bit in the view is cleared.

Source

pub fn any_set(&self) -> bool

Returns true if any bit in the view is set.

Source

pub fn slice(&self, offset: usize, len: usize) -> Self

Slices the view further by logical offset and len (relative to this window).

Source

pub fn end(&self) -> usize

Returns the exclusive end row index of the window (relative to bitmask).

Source

pub fn as_tuple(&self) -> BitmaskVT<'a>

Returns the underlying window as a tuple: (&Bitmask, offset, len).

Trait Implementations§

Source§

impl<'a> Clone for BitmaskV<'a>

Source§

fn clone(&self) -> BitmaskV<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for BitmaskV<'a>

Source§

impl<'a> Debug for BitmaskV<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Display for BitmaskV<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a Array> for BitmaskV<'a>

Extract the boolean data from an Array. Panics if not a BooleanArray variant.

Source§

fn from(arr: &'a Array) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a ArrayV> for BitmaskV<'a>

Available on crate feature views only.

Extract the boolean data from an ArrayV, preserving the view’s offset and length. Panics if the underlying array is not a BooleanArray variant.

Source§

fn from(av: &'a ArrayV) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a Bitmask> for BitmaskV<'a>

View over the full bitmask with zero offset.

Source§

fn from(bitmask: &'a Bitmask) -> Self

Converts to this type from the input type.
Source§

impl<'a, T> From<&'a BooleanArray<T>> for BitmaskV<'a>

View over a BooleanArray’s data bitmask with zero offset.

Source§

fn from(arr: &'a BooleanArray<T>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<BitmaskV<'a>> for Value

Available on crate feature views only.

Wrap a BitmaskV as Value::ArrayView of a BooleanArray. The bitmask data is taken as the BooleanArray’s data; null_mask is None since BitmaskV carries no separate null mask.

Source§

fn from(v: BitmaskV<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> Index<usize> for BitmaskV<'a>

Source§

fn index(&self, index: usize) -> &Self::Output

Returns a reference to a constant true or false value depending on the bit at index.

Note: This does not return a reference into the underlying bitmask storage. The reference points to a compiler-promoted static constant, so its address is unrelated to the internal buffer. Use Self::get if you need the value directly.

Source§

type Output = bool

The returned type after indexing.
Source§

impl<'a> PartialEq for BitmaskV<'a>

Source§

fn eq(&self, other: &BitmaskV<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> Shape for BitmaskV<'a>

Source§

fn shape(&self) -> ShapeDim

Returns arbitrary Shape dimension for any data shape
Source§

fn shape_1d(&self) -> usize

Returns the first dimension shape Read more
Source§

fn shape_2d(&self) -> (usize, usize)

Returns the first and second dimension shapes Read more
Source§

fn shape_3d(&self) -> (usize, usize, usize)

Returns the first, second and third dimension shapes Read more
Source§

fn shape_4d(&self) -> (usize, usize, usize, usize)

Returns the first, second, third and fourth dimension shapes Read more
Source§

impl<'a> StructuralPartialEq for BitmaskV<'a>

Source§

impl<'a> TryFrom<&'a Value> for BitmaskV<'a>

Available on crate feature views only.

Borrow a Value as a windowed BitmaskV over its boolean data.

The view borrows the Value, so the Value must outlive it. An ArrayView preserves the inner view’s offset and length. An owned Array windows the whole boolean column.

Source§

type Error = MinarrowError

The type returned in the event of a conversion error.
Source§

fn try_from(v: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a> Freeze for BitmaskV<'a>

§

impl<'a> RefUnwindSafe for BitmaskV<'a>

§

impl<'a> Send for BitmaskV<'a>

§

impl<'a> Sync for BitmaskV<'a>

§

impl<'a> Unpin for BitmaskV<'a>

§

impl<'a> UnsafeUnpin for BitmaskV<'a>

§

impl<'a> UnwindSafe for BitmaskV<'a>

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CustomValue for T
where T: Any + Send + Sync + Clone + PartialEq + Debug,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Downcasts the type as Any
Source§

fn deep_clone(&self) -> Arc<dyn CustomValue>

Returns a deep clone of the object. Read more
Source§

fn eq_box(&self, other: &(dyn CustomValue + 'static)) -> bool

Performs semantic equality on the boxed object. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Key for T
where T: Clone,

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Print for T
where T: Display,

Source§

fn print(&self)
where Self: Display,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.