pub struct DDSketch { /* private fields */ }Expand description
A DDSketch quantile sketch with relative-error guarantees.
The sketch stores counts in a BTreeMap keyed by bucket index.
The bucket index for a positive value v is
floor(log(v) / log(gamma)) where gamma = (1 + alpha) / (1 - alpha).
Zero has a special bucket index of i64::MIN.
Implementations§
Source§impl DDSketch
impl DDSketch
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new DDSketch with the default relative error (1%) and max buckets (8192).
Sourcepub fn with_alpha(alpha: f64, max_buckets: usize) -> Self
pub fn with_alpha(alpha: f64, max_buckets: usize) -> Self
Create a new DDSketch with the given relative error and max
buckets. alpha must be in (0, 1).
Sourcepub fn add(&mut self, v: f64)
pub fn add(&mut self, v: f64)
Record a value into the sketch. The value is non-negative (latencies). Negative values are treated as zero.
Sourcepub fn quantile(&self, p: f64) -> f64
pub fn quantile(&self, p: f64) -> f64
Estimate the quantile at p (0.0 to 1.0). Returns 0.0 if no
samples have been recorded. The returned value is within
(1 + alpha) of the true quantile.
The estimate is the lower bound of the bucket containing the
target rank. This is a conservative (lower) estimate; the true
quantile is in [estimate, estimate * gamma].
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DDSketch
impl RefUnwindSafe for DDSketch
impl Send for DDSketch
impl Sync for DDSketch
impl Unpin for DDSketch
impl UnwindSafe for DDSketch
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§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
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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