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
impl Coverage
Sourcepub fn from_bitmap(bitmap: RoaringBitmap) -> Self
pub fn from_bitmap(bitmap: RoaringBitmap) -> Self
Wrap an existing RoaringBitmap as Coverage.
Sourcepub fn present(&self) -> &RoaringBitmap
pub fn present(&self) -> &RoaringBitmap
Borrow the underlying bitmap of present buckets.
Sourcepub fn into_bitmap(self) -> RoaringBitmap
pub fn into_bitmap(self) -> RoaringBitmap
Consume the Coverage and return the underlying bitmap.
Sourcepub fn intersect(&self, other: &Coverage) -> Coverage
pub fn intersect(&self, other: &Coverage) -> Coverage
Return the intersection of self and other.
Sourcepub fn cardinality(&self) -> u64
pub fn cardinality(&self) -> u64
Number of buckets present in this coverage.
Sourcepub fn missing_points(&self, expected: &RoaringBitmap) -> RoaringBitmap
pub fn missing_points(&self, expected: &RoaringBitmap) -> RoaringBitmap
Return bucket ids that are expected but not present in this coverage.
This is expected - present.
Sourcepub fn missing_runs(
&self,
expected: &RoaringBitmap,
max_run_len: Option<u64>,
) -> Vec<RangeInclusive<Bucket>>
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.
expecteddefines the domain we care about.- Missing buckets are
expected - present. - Each returned range is inclusive in bucket space.
Sourcepub fn last_run_with_min_len(
&self,
expected: &RoaringBitmap,
min_len: u64,
) -> Option<RangeInclusive<Bucket>>
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().
Sourcepub fn coverage_ratio(&self, expected: &RoaringBitmap) -> f64
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).
Sourcepub fn max_gap_len(&self, expected: &RoaringBitmap) -> u64
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.
Sourcepub fn union_inplace(&mut self, other: &Coverage)
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.
Sourcepub fn last_window_at_or_before(
&self,
end_bucket: Bucket,
len: u64,
) -> Option<RangeInclusive<Bucket>>
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§
Auto Trait Implementations§
impl Freeze for Coverage
impl RefUnwindSafe for Coverage
impl Send for Coverage
impl Sync for Coverage
impl Unpin for Coverage
impl UnsafeUnpin for Coverage
impl UnwindSafe for Coverage
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