quantile

package module
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNonMonotonicBoundaries = "explicit bucket histogram: non-monotonic boundaries"
)

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Buf      []Key
	CountBuf []KeyCount
	Sketch   Sketch
}

An Agent sketch is an insert optimized version of the sketch for use in the datadog-agent.

func (*Agent) Finish

func (a *Agent) Finish() *Sketch

Finish flushes any pending inserts and returns a deep copy of the sketch.

func (*Agent) Insert

func (a *Agent) Insert(v float64, sampleRate float64)

Insert v into the sketch.

func (*Agent) InsertInterpolate

func (a *Agent) InsertInterpolate(lower float64, upper float64, count uint) error

InsertInterpolate linearly interpolates a count from the given lower to upper bounds

func (*Agent) IsEmpty

func (a *Agent) IsEmpty() bool

IsEmpty returns true if the sketch is empty

func (*Agent) Reset

func (a *Agent) Reset()

Reset the agent sketch to the empty state.

type Bound added in v0.30.0

type Bound struct {
	// Key is the quantized value of the bound.
	Key Key
	Low float64 // Low is the lower bound of the range.
}

type Config

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

A Config struct is passed around to many sketches (read-only).

func Default

func Default() *Config

Default returns the default config.

func NewConfig

func NewConfig(eps, min float64, binLimit int) (*Config, error)

NewConfig creates a config object with. TODO|DOC: describe params

func (*Config) MaxCount

func (c *Config) MaxCount() int

MaxCount returns the max number of values you can insert. This is limited by using a uint16 for bin.n

type DDSketchBinGenerator added in v0.30.0

type DDSketchBinGenerator struct {
	// Config is the configuration for the sketch.
	Config   *Config
	Bounds   []Bound
	BoundMap map[Key]*Bound
}

func NewDDSketchBinGenerator added in v0.30.0

func NewDDSketchBinGenerator(config *Config) *DDSketchBinGenerator

func NewDDSketchBinGeneratorForAgent added in v0.30.0

func NewDDSketchBinGeneratorForAgent() *DDSketchBinGenerator

func (*DDSketchBinGenerator) GetBound added in v0.30.0

func (g *DDSketchBinGenerator) GetBound(key Key) (*Bound, bool)

func (*DDSketchBinGenerator) GetBounds added in v0.30.0

func (g *DDSketchBinGenerator) GetBounds() []Bound

func (*DDSketchBinGenerator) GetKeyForValue added in v0.30.0

func (g *DDSketchBinGenerator) GetKeyForValue(value float64) Key

type Key

type Key int16

A Key represents a quantized version of a float64. See Config for more details

func InfKey

func InfKey(sign int) Key

InfKey returns the Key for +Inf if sign >= 0, -Inf if sign < 0.

func (Key) IsInf

func (k Key) IsInf() bool

IsInf returns true if the key represents +/-Inf

func (Key) String

func (k Key) String() string

type KeyCount

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

A KeyCount represents a Key and an associated count

type Sketch

type Sketch struct {
	Basic summary.Summary `json:"summary"`
	// contains filtered or unexported fields
}

A Sketch for tracking quantiles The serialized JSON of Sketch contains the summary only Bins are not included.

func ConvertDDSketchIntoSketch

func ConvertDDSketchIntoSketch(inputSketch *ddsketch.DDSketch) (*Sketch, error)

ConvertDDSketchIntoSketch converts a DDSketch into a Sketch, by first converting the DDSketch into a new DDSketch with a mapping that's compatible with Sketch parameters, then creating the Sketch by copying the DDSketch bins to the Sketch store.

func (*Sketch) ApproxEquals

func (s *Sketch) ApproxEquals(o *Sketch, e float64) bool

ApproxEquals checks if s and o are equivalent, with e error allowed for Sum and Average

func (*Sketch) Cols

func (s *Sketch) Cols() (k []int32, n []uint32)

Cols returns an array of k and n.

func (*Sketch) Copy

func (s *Sketch) Copy() *Sketch

Copy returns a deep copy

func (*Sketch) CopyTo

func (s *Sketch) CopyTo(dst *Sketch)

CopyTo makes a deep copy of this sketch into dst.

func (*Sketch) Equals

func (s *Sketch) Equals(o *Sketch) bool

Equals returns true if s and o are equivalent.

func (*Sketch) GetRawBins

func (s *Sketch) GetRawBins() (int, string)

GetRawBins return raw bins information as string

func (*Sketch) Insert

func (s *Sketch) Insert(c *Config, vals ...float64)

Insert a single value into the sketch. NOTE: InsertMany is much more efficient.

func (*Sketch) InsertMany

func (s *Sketch) InsertMany(c *Config, values []float64)

InsertMany values into the sketch.

func (*Sketch) MemSize

func (s *Sketch) MemSize() (used, allocated int)

MemSize returns memory use in bytes:

used: uses len(bins)
allocated: uses cap(bins)

func (*Sketch) Merge

func (s *Sketch) Merge(c *Config, o *Sketch)

Merge o into s, without mutating o.

func (*Sketch) Quantile

func (s *Sketch) Quantile(c *Config, q float64) float64

Quantile returns v such that s.count*q items are <= v.

Special cases are:

	Quantile(c, q <= 0)  = min
 Quantile(c, q >= 1)  = max

func (*Sketch) Reset

func (s *Sketch) Reset()

Reset sketch to its empty state.

func (*Sketch) String

func (s *Sketch) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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