Struct re_int_histogram::Int64Histogram

source ·
pub struct Int64Histogram {
    root: Node,
}
Expand description

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

Fields§

§root: Node

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 decrement(&mut self, key: i64, dec: u32) -> u32

Decrement the count for the given key.

The decrement is saturating.

Returns how much was actually decremented (found). If the returned value is less than the given value, it means that the key was either no found, or had a lower count.

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.

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.

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