Documentation
¶
Overview ¶
Package hll implements a HyperLogLog sketch over uniformly distributed 64-bit hashes.
Index ¶
Constants ¶
const Precision = 14
Precision is the number of leading hash bits that select a register.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sketch ¶
type Sketch struct {
// contains filtered or unexported fields
}
Sketch is a HyperLogLog sketch. Add calls may run concurrently with each other and with Estimate. Reset may run concurrently with Add, but then it does not guarantee that the Add is kept: callers that need a value added during a Reset to be counted must serialize the two.
func (*Sketch) Add ¶
Add records x. The registers are chosen by the bits of x, so x must be a uniformly distributed 64-bit hash, such as a series ID; raw sequential values skew the estimate.
func (*Sketch) Estimate ¶
Estimate returns the estimated number of distinct values added since creation or the last Reset. An estimate that does not fit in a uint64 is capped at math.MaxUint64. It uses the improved raw estimator of Ertl (https://arxiv.org/abs/1702.01284), which has no bias over the whole cardinality range and needs no linear counting switch or bias table.