Lens AI Profiler Cpp
Public Member Functions | List of all members
KLLSketch Class Reference

A sketch data structure for approximate quantile estimation. More...

#include <kll.h>

Public Member Functions

 KLLSketch (int maxBins)
 Constructs a KLLSketch object with the specified maximum number of bins. More...
 
void update (double value)
 Updates the sketch with a new data point. More...
 
double getQuantile (double quantile)
 Estimates the quantile of the data stream represented by the sketch. More...
 

Detailed Description

A sketch data structure for approximate quantile estimation.

This class represents a KLL sketch, which can be used to estimate quantiles of a data stream in an approximate but memory-efficient way.

Constructor & Destructor Documentation

◆ KLLSketch()

KLLSketch::KLLSketch ( int  maxBins)

Constructs a KLLSketch object with the specified maximum number of bins.

A sketch data structure for approximate quantile estimation using the KLL algorithm.

Parameters
maxBinsThe maximum number of bins to store in the sketch.

This class implements the KLL sketch data structure, which can be used to estimate quantiles of a data stream in an approximate but memory-efficient way.

Constructs a KLLSketch object with the specified maximum number of bins.

Parameters
maxBinsThe maximum number of bins to store in the sketch.

Member Function Documentation

◆ getQuantile()

double KLLSketch::getQuantile ( double  quantile)

Estimates the quantile of the data stream represented by the sketch.

This function estimates the value at a specific quantile (e.g., median) based on the data points stored in the sketch.

Parameters
quantileThe quantile value (between 0.0 and 1.0).
Returns
The estimated value at the specified quantile.

◆ update()

void KLLSketch::update ( double  value)

Updates the sketch with a new data point.

This function adds a new data point to the sketch and maintains the internal state for quantile estimation. If the number of data points exceeds the maximum number of bins, the mergeBins() function is called to reduce the number of bins.

Parameters
valueThe data point to be added to the sketch.

The documentation for this class was generated from the following files: