Documentation ¶
Overview ¶
Package tdigest provides a highly accurate mergeable data-structure for quantile estimation.
Index ¶
- type TDigest
- func (t *TDigest) Add(value float64, count uint32) error
- func (t TDigest) AsBytes() ([]byte, error)
- func (t *TDigest) Compress()
- func (t *TDigest) ForEachCentroid(f func(mean float64, count uint32) bool)
- func (t *TDigest) Len() int
- func (t *TDigest) Merge(other *TDigest)
- func (t *TDigest) Quantile(q float64) float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TDigest ¶
type TDigest struct {
// contains filtered or unexported fields
}
TDigest is a quantile approximation data structure. Typical T-Digest use cases involve accumulating metrics on several distinct nodes of a cluster and then merging them together to get a system-wide quantile overview. Things such as: sensory data from IoT devices, quantiles over enormous document datasets (think ElasticSearch), performance metrics for distributed systems, etc.
func FromBytes ¶
FromBytes reads a byte buffer with a serialized digest (from AsBytes) and deserializes it.
func New ¶
New creates a new digest. The compression parameter rules the threshold in which samples are merged together - the more often distinct samples are merged the more precision is lost. Compression should be tuned according to your data distribution, but a value of 100 is often good enough. A higher compression value means holding more centroids in memory (thus: better precision), which means a bigger serialization payload and higher memory footprint. Compression must be a value greater of equal to 1, will panic otherwise.
func (*TDigest) Add ¶
Add registers a new sample in the digest. It's the main entry point for the digest and very likely the only method to be used for collecting samples. The count parameter is for when you are registering a sample that occurred multiple times - the most common value for this is 1.
func (TDigest) AsBytes ¶
AsBytes serializes the digest into a byte array so it can be saved to disk or sent over the wire.
func (*TDigest) Compress ¶
func (t *TDigest) Compress()
Compress tries to reduce the number of individual centroids stored in the digest. Compression trades off accuracy for performance and happens automatically after a certain amount of distinct samples have been stored.
func (*TDigest) ForEachCentroid ¶
ForEachCentroid calls the specified function for each centroid. Iteration stops when the supplied function returns false, or when all centroids have been iterated.