Skip to main content

Coverage

Struct Coverage 

Source
pub struct Coverage { /* private fields */ }
Expand description

In-memory coverage over a discrete set of bucket ids.

This is a thin wrapper over RoaringBitmap that adds convenience methods for gap analysis.

Implementations§

Source§

impl Coverage

Source

pub fn empty() -> Self

Construct an empty coverage set (no bucket present).

Source

pub fn from_bitmap(bitmap: RoaringBitmap) -> Self

Wrap an existing RoaringBitmap as Coverage.

Source

pub fn present(&self) -> &RoaringBitmap

Borrow the underlying bitmap of present buckets.

Source

pub fn into_bitmap(self) -> RoaringBitmap

Consume the Coverage and return the underlying bitmap.

Source

pub fn union(&self, other: &Coverage) -> Coverage

Return the union of self and other.

Source

pub fn intersect(&self, other: &Coverage) -> Coverage

Return the intersection of self and other.

Source

pub fn cardinality(&self) -> u64

Number of buckets present in this coverage.

Source

pub fn missing_points(&self, expected: &RoaringBitmap) -> RoaringBitmap

Return bucket ids that are expected but not present in this coverage.

This is expected - present.

Source

pub fn missing_runs( &self, expected: &RoaringBitmap, max_run_len: Option<u64>, ) -> Vec<RangeInclusive<Bucket>>

Group missing buckets into contiguous runs, optionally splitting long runs into chunks of at most max_run_len.

  • expected defines the domain we care about.
  • Missing buckets are expected - present.
  • Each returned range is inclusive in bucket space.
Source

pub fn last_run_with_min_len( &self, expected: &RoaringBitmap, min_len: u64, ) -> Option<RangeInclusive<Bucket>>

Return the last (highest) contiguous run of coverage of length at least min_len, relative to expected.

“Coverage” here means buckets that are both in expected and in self.present().

Source

pub fn coverage_ratio(&self, expected: &RoaringBitmap) -> f64

Coverage ratio in [0.0, 1.0] relative to expected.

Defined as:

(|present ∩ expected| as f64) / (|expected| as f64)

For expected.is_empty(), this returns 1.0 by convention (vacuous full coverage).

Source

pub fn max_gap_len(&self, expected: &RoaringBitmap) -> u64

Maximum gap length (in buckets) relative to expected.

This is the length (number of buckets) of the longest missing run. If there are no missing buckets, returns 0.

Source

pub fn union_inplace(&mut self, other: &Coverage)

Merge another coverage bitmap into this one, accumulating all buckets.

This performs an in-place union, so after the call self contains every bucket that was set in either self or other.

Source

pub fn last_window_at_or_before( &self, end_bucket: Bucket, len: u64, ) -> Option<RangeInclusive<Bucket>>

Return the last fully-covered contiguous window of length len ending at or before end_bucket, based on present buckets only.

Trait Implementations§

Source§

impl Clone for Coverage

Source§

fn clone(&self) -> Coverage

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Coverage

Source§

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

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

impl Default for Coverage

Source§

fn default() -> Coverage

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

impl FromIterator<u32> for Coverage

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = Bucket>,

Creates a value from an iterator. Read more

Auto Trait Implementations§

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> 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<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> 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> 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> 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, 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.
Source§

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