cm

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 3 Imported by: 5 modules, 12 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cm implements the Cormode-Muthukrishnan algorithm for computing biased quantiles over data streams from "Effective Computation of Biased Quantiles over Data Streams" and is largely based on statsite's implementation in C: https://github.com/statsite/statsite/blob/master/src/cm_quantile.c

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options interface {
	// SetEps sets the desired epsilon for errors.
	SetEps(value float64) Options

	// Eps returns the desired epsilon for errors.
	Eps() float64

	// SetCapacity sets the initial heap capacity.
	SetCapacity(value int) Options

	// Capacity returns the initial heap capacity.
	Capacity() int

	// SetInsertAndCompressEvery sets how frequently the timer values are
	// inserted into the stream and compressed to reduce write latency for
	// high frequency timers.
	SetInsertAndCompressEvery(value int) Options

	// InsertAndCompressEvery returns how frequently the timer values are
	// inserted into the stream and compressed to reduce write latency for
	// high frequency timers.
	InsertAndCompressEvery() int

	// SetStreamPool sets the stream pool.
	SetStreamPool(value StreamPool) Options

	// StreamPool returns the stream pool.
	StreamPool() StreamPool

	// Validate validates the options.
	Validate() error
}

Options represent various options for computing quantiles.

func NewOptions

func NewOptions() Options

NewOptions creates a new options.

type Sample

type Sample struct {
	// contains filtered or unexported fields
}

Sample represents a sampled value.

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

Stream represents a data stream.

func NewStream

func NewStream(opts Options) *Stream

NewStream creates a new sample stream.

func (*Stream) Add

func (s *Stream) Add(value float64)

Add adds a sample value.

func (*Stream) AddBatch added in v1.2.0

func (s *Stream) AddBatch(values []float64)

AddBatch adds a batch of sample values.

func (*Stream) Close

func (s *Stream) Close()

Close closes the stream.

func (*Stream) Flush

func (s *Stream) Flush()

Flush flushes the internal buffer.

func (*Stream) Max

func (s *Stream) Max() float64

Max returns the maximum value.

func (*Stream) Min

func (s *Stream) Min() float64

Min returns the minimum value.

func (*Stream) Quantile

func (s *Stream) Quantile(q float64) float64

Quantile returns the quantile value.

func (*Stream) ResetSetData

func (s *Stream) ResetSetData(quantiles []float64)

ResetSetData resets the stream and sets data.

type StreamPool

type StreamPool struct {
	// contains filtered or unexported fields
}

StreamPool is a pool of streams, wrapping sync.Pool.

func NewStreamPool

func NewStreamPool(opts Options) StreamPool

NewStreamPool creates a new StreamPool.

func (StreamPool) Get

func (p StreamPool) Get() *Stream

Get returns a new Stream from the pool.

func (StreamPool) Put

func (p StreamPool) Put(s *Stream)

Put puts a Stream back into the pool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL