Crate reqsketch

Crate reqsketch 

Source
Expand description

§REQSketch - Relative Error Quantiles Sketch

Relative Error Quantiles sketch algorithm in Rust. This implementation is based on the paper “Relative Error Streaming Quantiles” by Graham Cormode, Zohar Karnin, Edo Liberty, Justin Thaler, Pavel Veselý.

And on the C++ implementation in Apache DataSketches https://github.com/apache/datasketches-cpp

§Quick Start

use reqsketch::{ReqSketch, SearchCriteria, Result};

fn main() -> Result<()> {
    let mut sketch = ReqSketch::new();

    // Add values to the sketch
    for i in 0..10000 {
        sketch.update(i as f64);
    }

    // Query quantiles with proper error handling
    let median = sketch.quantile(0.5, SearchCriteria::Inclusive)?;
    let p99 = sketch.quantile(0.99, SearchCriteria::Inclusive)?;

    // Query ranks with proper error handling
    let rank = sketch.rank(&5000.0, SearchCriteria::Inclusive)?;

    println!("Median: {}, P99: {}, Rank of 5000: {}", median, p99, rank);
    Ok(())
}

Re-exports§

pub use builder::ReqSketchBuilder;
pub use error::ReqError;
pub use error::Result;
pub use iter::ReqSketchIterator;
pub use sorted_view::SortedView;

Modules§

builder
Builder pattern implementation for REQ sketch construction.
compactor
Compactor implementation for REQ sketch levels.
error
Error types for the REQ sketch library.
iter
Iterator implementations for REQ sketch inspection.
sorted_view
Sorted view implementation for efficient quantile queries.

Structs§

ReqSketch
A Relative Error Quantiles sketch for approximate quantile estimation.

Enums§

RankAccuracy
Configuration for rank accuracy optimization
SearchCriteria
Search criteria for quantile/rank operations

Traits§

ReqKey
Trait for types that can be used efficiently in REQ sketches. Implemented for numeric types that support fast copy semantics.
TotalOrd
Trait for total ordering that handles NaN consistently.