pub struct Int64Histogram { /* private fields */ }
Expand description

A histogram, mapping i64 key to a u64 count optimizing for very fast range-queries.

Implementations§

source§

impl Int64Histogram

source

pub fn increment(&mut self, key: i64, inc: u32)

Increment the count for the given key.

Incrementing with one is similar to inserting the key in a multi-set.

source

pub fn is_empty(&self) -> bool

Is the total count zero?

Note that incrementing a key with zero is a no-op and will leave an empty histogram still empty.

source

pub fn total_count(&self) -> u64

Total count of all the buckets.

NOTE: this is NOT the number of unique keys.

source

pub fn min_key(&self) -> Option<i64>

Lowest key with a non-zero count.

source

pub fn max_key(&self) -> Option<i64>

Highest key with a non-zero count.

source

pub fn range_count(&self, range: impl RangeBounds<i64>) -> u64

What is the count of all the buckets in the given range?

source

pub fn range(&self, range: impl RangeBounds<i64>, cutoff_size: u64) -> Iter<'_>

Iterate over a certain range, returning ranges that are at most cutoff_size long.

To get all individual entries, use cutoff_size<=1.

When cutoff_size > 1 you MAY get ranges which include keys that has no count. However, the ends (min/max) of all returned ranges will be keys with a non-zero count.

In other words, gaps in the key-space smaller than cutoff_size MAY be ignored by this iterator.

For example, inserting two elements at 10 and 15 and setting a cutoff_size=10 you may get a single range [10, 15] with the total count. You may also get two ranges of [10, 10] and [15, 15].

A larger cutoff_size will generally yield fewer ranges, and will be faster.

source

pub fn remove(&mut self, range: impl RangeBounds<i64>) -> u64

Remove all data in the given range.

Returns how much count was removed.

Currently the implementation is optimized for the case of removing large continuous ranges. Removing many small, scattered ranges (e.g. individual elements) may cause performance problems! This can be remedied with some more code.

Trait Implementations§

source§

impl Clone for Int64Histogram

source§

fn clone(&self) -> Int64Histogram

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

impl Debug for Int64Histogram

source§

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

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

impl Default for Int64Histogram

source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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> ToOwned for Twhere 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 Twhere 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 Twhere 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.