pub struct SortedView<T> { /* private fields */ }req only.Expand description
An owned, sorted snapshot of a ReqSketch.
Obtain one with ReqSketch::sorted_view.
The view is independent of the sketch: it can be queried (and sent to other
threads) while the sketch keeps receiving updates, and it keeps answering
from the state it was taken at. Building it costs O(retained · log retained);
each subsequent query is O(log retained), so it is the right tool for
repeated quantile/rank queries.
Implementations§
Source§impl<T> SortedView<T>
impl<T> SortedView<T>
Sourcepub fn total_weight(&self) -> u64
pub fn total_weight(&self) -> u64
Returns the total weight (stream length captured) of all items.
Sourcepub fn rank(&self, item: &T, criteria: SearchCriteria) -> Result<f64, Error>
pub fn rank(&self, item: &T, criteria: SearchCriteria) -> Result<f64, Error>
Returns the approximate normalized rank of item in [0.0, 1.0].
§Errors
Returns an error if the view is empty.
Sourcepub fn quantile(&self, rank: f64, criteria: SearchCriteria) -> Result<T, Error>
pub fn quantile(&self, rank: f64, criteria: SearchCriteria) -> Result<T, Error>
Returns the approximate quantile at the given normalized rank.
§Errors
Returns an error if the view is empty or rank is outside [0.0, 1.0].
Sourcepub fn pmf(
&self,
split_points: &[T],
criteria: SearchCriteria,
) -> Result<Vec<f64>, Error>
pub fn pmf( &self, split_points: &[T], criteria: SearchCriteria, ) -> Result<Vec<f64>, Error>
Returns the probability mass function (PMF) over the given split points.
The result contains one more value than split_points.
§Errors
Returns an error if the view is empty or the split points are not strictly increasing.
Sourcepub fn cdf(
&self,
split_points: &[T],
criteria: SearchCriteria,
) -> Result<Vec<f64>, Error>
pub fn cdf( &self, split_points: &[T], criteria: SearchCriteria, ) -> Result<Vec<f64>, Error>
Returns the cumulative distribution function (CDF) over the given split points.
The result contains one more value than split_points and ends at 1.0.
§Errors
Returns an error if the view is empty or the split points are not strictly increasing.
Trait Implementations§
Source§impl<T: Clone> Clone for SortedView<T>
impl<T: Clone> Clone for SortedView<T>
Source§fn clone(&self) -> SortedView<T>
fn clone(&self) -> SortedView<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more