Skip to main content

quantile_from_parts

Function quantile_from_parts 

Source
fn quantile_from_parts(
    q: f64,
    schema: i32,
    count_total: f64,
    sum: f64,
    negative_empty: bool,
    positive_empty: bool,
    buckets: impl FnOnce() -> Option<Vec<Bucket>>,
) -> (f64, Option<NativeHistogramQuantileInfo>)
Expand description

Estimates a quantile from histogram metadata and a lazily materialized bucket sequence.

This is the estimator NativeHistogram::quantile_with_info and quantile_histogram_view expose, so it stays for callers of this crate. The PromQL histogram_quantile does not use it: that function reads the same histogram through the native kernel in the promql crate, which walks the buckets the way Prometheus does – from the highest bucket down for a quantile above the median – so one histogram has one answer instead of two that differ in their last places. The exponential boundary below interpolates with 2^x, which likewise stays only for this estimator; the kernel interpolates with exp2 over Prometheus’s bound table.