Struct rerun::external::re_chunk_store::external::arrow2::bitmap::Bitmap

pub struct Bitmap {
    bytes: Arc<Bytes<u8>>,
    offset: usize,
    length: usize,
    unset_bits: usize,
}
Expand description

An immutable container semantically equivalent to Arc<Vec<bool>> but represented as Arc<Vec<u8>> where each boolean is represented as a single bit.

§Examples

use re_arrow2::bitmap::{Bitmap, MutableBitmap};

let bitmap = Bitmap::from([true, false, true]);
assert_eq!(bitmap.iter().collect::<Vec<_>>(), vec![true, false, true]);

// creation directly from bytes
let bitmap = Bitmap::try_new(vec![0b00001101], 5).unwrap();
// note: the first bit is the left-most of the first byte
assert_eq!(bitmap.iter().collect::<Vec<_>>(), vec![true, false, true, true, false]);
// we can also get the slice:
assert_eq!(bitmap.as_slice(), ([0b00001101u8].as_ref(), 0, 5));
// debug helps :)
assert_eq!(format!("{:?}", bitmap), "[0b___01101]".to_string());

// it supports copy-on-write semantics (to a `MutableBitmap`)
let bitmap: MutableBitmap = bitmap.into_mut().right().unwrap();
assert_eq!(bitmap, MutableBitmap::from([true, false, true, true, false]));

// slicing is 'O(1)' (data is shared)
let bitmap = Bitmap::try_new(vec![0b00001101], 5).unwrap();
let mut sliced = bitmap.clone();
sliced.slice(1, 4);
assert_eq!(sliced.as_slice(), ([0b00001101u8].as_ref(), 1, 4)); // 1 here is the offset:
assert_eq!(format!("{:?}", sliced), "[0b___0110_]".to_string());
// when sliced (or cloned), it is no longer possible to `into_mut`.
let same: Bitmap = sliced.into_mut().left().unwrap();

Fields§

§bytes: Arc<Bytes<u8>>§offset: usize§length: usize§unset_bits: usize

Implementations§

§

impl Bitmap

pub fn new() -> Bitmap

Initializes an empty Bitmap.

pub fn try_new(bytes: Vec<u8>, length: usize) -> Result<Bitmap, Error>

Initializes a new Bitmap from vector of bytes and a length.

§Errors

This function errors iff length > bytes.len() * 8

pub fn len(&self) -> usize

Returns the length of the Bitmap.

pub fn is_empty(&self) -> bool

Returns whether Bitmap is empty

pub fn iter(&self) -> BitmapIter<'_>

Returns a new iterator of bool over this bitmap

pub fn chunks<T>(&self) -> BitChunks<'_, T>
where T: BitChunk,

Returns an iterator over bits in bit chunks BitChunk.

This iterator is useful to operate over multiple bits via e.g. bitwise.

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

Returns the byte slice of this Bitmap.

The returned tuple contains:

  • .1: The byte slice, truncated to the start of the first bit. So the start of the slice is within the first 8 bits.
  • .2: The start offset in bits on a range 0 <= offsets < 8.
  • .3: The length in number of bits.

pub const fn unset_bits(&self) -> usize

Returns the number of unset bits on this Bitmap.

Guaranteed to be <= self.len().

§Implementation

This function is O(1) - the number of unset bits is computed when the bitmap is created

pub fn null_count(&self) -> usize

👎Deprecated since 0.13.0: use unset_bits instead

Returns the number of unset bits on this Bitmap.

pub fn slice(&mut self, offset: usize, length: usize)

Slices self, offsetting by offset and truncating up to length bits.

§Panic

Panics iff offset + length > self.length, i.e. if the offset and length exceeds the allocated capacity of self.

pub unsafe fn slice_unchecked(&mut self, offset: usize, length: usize)

Slices self, offseting by offset and truncating up to length bits.

§Safety

The caller must ensure that self.offset + offset + length <= self.len()

pub fn sliced(self, offset: usize, length: usize) -> Bitmap

Slices self, offsetting by offset and truncating up to length bits.

§Panic

Panics iff offset + length > self.length, i.e. if the offset and length exceeds the allocated capacity of self.

pub unsafe fn sliced_unchecked(self, offset: usize, length: usize) -> Bitmap

Slices self, offseting by offset and truncating up to length bits.

§Safety

The caller must ensure that self.offset + offset + length <= self.len()

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

Returns whether the bit at position i is set.

§Panics

Panics iff i >= self.len().

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

Unsafely returns whether the bit at position i is set.

§Safety

Unsound iff i >= self.len().

pub fn into_mut(self) -> Either<Bitmap, MutableBitmap>

Converts this Bitmap to MutableBitmap, returning itself if the conversion is not possible

This operation returns a MutableBitmap iff:

  • this Bitmap is not an offsetted slice of another Bitmap
  • this Bitmap has not been cloned (i.e. Arc::get_mut yields Some)
  • this Bitmap was not imported from the c data interface (FFI)

pub fn make_mut(self) -> MutableBitmap

Converts this Bitmap into a MutableBitmap, cloning its internal buffer if required (clone-on-write).

pub fn new_constant(value: bool, length: usize) -> Bitmap

Initializes an new Bitmap filled with set/unset values.

pub fn new_zeroed(length: usize) -> Bitmap

Initializes an new Bitmap filled with unset values.

pub fn new_trued(length: usize) -> Bitmap

Initializes an new Bitmap filled with set values.

pub fn null_count_range(&self, offset: usize, length: usize) -> usize

Counts the nulls (unset bits) starting from offset bits and for length bits.

pub fn from_u8_slice<T>(slice: T, length: usize) -> Bitmap
where T: AsRef<[u8]>,

Creates a new Bitmap from a slice and length.

§Panic

Panics iff length <= bytes.len() * 8

pub fn from_u8_vec(vec: Vec<u8>, length: usize) -> Bitmap

Alias for Bitmap::try_new().unwrap() This function is O(1)

§Panic

This function panics iff length <= bytes.len() * 8

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

Returns whether the bit at position i is set.

pub fn into_inner(self) -> (Arc<Bytes<u8>>, usize, usize, usize)

Returns its internal representation

pub unsafe fn from_inner( bytes: Arc<Bytes<u8>>, offset: usize, length: usize, unset_bits: usize ) -> Result<Bitmap, Error>

Creates a [Bitmap] from its internal representation. This is the inverted from [Bitmap::into_inner]

§Safety

The invariants of this struct must be upheld

pub unsafe fn from_inner_unchecked( bytes: Arc<Bytes<u8>>, offset: usize, length: usize, unset_bits: usize ) -> Bitmap

Creates a [Bitmap] from its internal representation. This is the inverted from [Bitmap::into_inner]

§Safety

Callers must ensure all invariants of this struct are upheld.

§

impl Bitmap

pub unsafe fn from_trusted_len_iter_unchecked<I>(iterator: I) -> Bitmap
where I: Iterator<Item = bool>,

Creates a new Bitmap from an iterator of booleans.

§Safety

The iterator must report an accurate length.

pub fn from_trusted_len_iter<I>(iterator: I) -> Bitmap
where I: TrustedLen<Item = bool>,

Creates a new Bitmap from an iterator of booleans.

pub fn try_from_trusted_len_iter<E, I>(iterator: I) -> Result<Bitmap, E>
where I: TrustedLen<Item = Result<bool, E>>,

Creates a new Bitmap from a fallible iterator of booleans.

pub unsafe fn try_from_trusted_len_iter_unchecked<E, I>( iterator: I ) -> Result<Bitmap, E>
where I: Iterator<Item = Result<bool, E>>,

Creates a new Bitmap from a fallible iterator of booleans.

§Safety

The iterator must report an accurate length.

pub fn from_null_buffer(value: NullBuffer) -> Bitmap

Create a new Bitmap from an arrow NullBuffer

Trait Implementations§

§

impl<'a, 'b> BitAnd<&'b Bitmap> for &'a Bitmap

§

type Output = Bitmap

The resulting type after applying the & operator.
§

fn bitand(self, rhs: &'b Bitmap) -> Bitmap

Performs the & operation. Read more
§

impl<'a> BitAnd<&'a Bitmap> for MutableBitmap

§

type Output = MutableBitmap

The resulting type after applying the & operator.
§

fn bitand(self, rhs: &'a Bitmap) -> MutableBitmap

Performs the & operation. Read more
§

impl<'a> BitAndAssign<&'a Bitmap> for &mut MutableBitmap

§

fn bitand_assign(&mut self, rhs: &'a Bitmap)

Performs the &= operation. Read more
§

impl<'a, 'b> BitOr<&'b Bitmap> for &'a Bitmap

§

type Output = Bitmap

The resulting type after applying the | operator.
§

fn bitor(self, rhs: &'b Bitmap) -> Bitmap

Performs the | operation. Read more
§

impl<'a> BitOr<&'a Bitmap> for MutableBitmap

§

type Output = MutableBitmap

The resulting type after applying the | operator.
§

fn bitor(self, rhs: &'a Bitmap) -> MutableBitmap

Performs the | operation. Read more
§

impl<'a> BitOrAssign<&'a Bitmap> for &mut MutableBitmap

§

fn bitor_assign(&mut self, rhs: &'a Bitmap)

Performs the |= operation. Read more
§

impl<'a, 'b> BitXor<&'b Bitmap> for &'a Bitmap

§

type Output = Bitmap

The resulting type after applying the ^ operator.
§

fn bitxor(self, rhs: &'b Bitmap) -> Bitmap

Performs the ^ operation. Read more
§

impl<'a> BitXor<&'a Bitmap> for MutableBitmap

§

type Output = MutableBitmap

The resulting type after applying the ^ operator.
§

fn bitxor(self, rhs: &'a Bitmap) -> MutableBitmap

Performs the ^ operation. Read more
§

impl<'a> BitXorAssign<&'a Bitmap> for &mut MutableBitmap

§

fn bitxor_assign(&mut self, rhs: &'a Bitmap)

Performs the ^= operation. Read more
§

impl Clone for Bitmap

§

fn clone(&self) -> Bitmap

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
§

impl Debug for Bitmap

§

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

Formats the value using the given formatter. Read more
§

impl Default for Bitmap

§

fn default() -> Bitmap

Returns the “default value” for a type. Read more
§

impl From<MutableBitmap> for Bitmap

§

fn from(buffer: MutableBitmap) -> Bitmap

Converts to this type from the input type.
§

impl<P> From<P> for Bitmap
where P: AsRef<[bool]>,

§

fn from(slice: P) -> Bitmap

Converts to this type from the input type.
§

impl FromIterator<bool> for Bitmap

§

fn from_iter<I>(iter: I) -> Bitmap
where I: IntoIterator<Item = bool>,

Creates a value from an iterator. Read more
§

impl<'a> IntoIterator for &'a Bitmap

§

type Item = bool

The type of the elements being iterated over.
§

type IntoIter = BitmapIter<'a>

Which kind of iterator are we turning this into?
§

fn into_iter(self) -> <&'a Bitmap as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
§

impl IntoIterator for Bitmap

§

type Item = bool

The type of the elements being iterated over.
§

type IntoIter = IntoIter

Which kind of iterator are we turning this into?
§

fn into_iter(self) -> <Bitmap as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
§

impl Not for &Bitmap

§

type Output = Bitmap

The resulting type after applying the ! operator.
§

fn not(self) -> Bitmap

Performs the unary ! operation. Read more
§

impl PartialEq for Bitmap

§

fn eq(&self, other: &Bitmap) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl Freeze for Bitmap

§

impl RefUnwindSafe for Bitmap

§

impl Send for Bitmap

§

impl Sync for Bitmap

§

impl Unpin for Bitmap

§

impl UnwindSafe for Bitmap

Blanket Implementations§

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> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

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

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

source§

fn lossy_into(self) -> Dst

Performs the conversion.
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

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

§

fn to<T>(self) -> T
where Self: Into<T>,

Converts to T by calling Into<T>::into.
§

fn try_to<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
source§

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

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
§

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

§

impl<T> Ungil for T
where T: Send,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,