Documentation
¶
Overview ¶
Package hll provides a HyperLogLog cardinality estimator.
HyperLogLog estimates the number of distinct elements in a multiset with approximately 2% standard error using only 2^p bytes of memory (e.g., 16 KB for precision 14). It is useful for counting unique items (developers, files, tokens) without maintaining a full set.
This implementation uses the LogLog-Beta bias correction from Qin et al. (2016), which provides accurate estimates across all cardinality ranges without the piecewise linear interpolation tables of HLL++.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPrecisionOutOfRange is returned when precision is not in [4, 18]. ErrPrecisionOutOfRange = errors.New("hll: precision must be in [4, 18]") // ErrPrecisionMismatch is returned when merging sketches with different precisions. ErrPrecisionMismatch = errors.New("hll: cannot merge sketches with different precisions") )
Functions ¶
This section is empty.
Types ¶
type Sketch ¶
type Sketch struct {
// contains filtered or unexported fields
}
Sketch is a thread-safe HyperLogLog cardinality estimator.
func New ¶
New creates a HyperLogLog sketch with the given precision p. Precision must be in [4, 18]. The sketch allocates 2^p registers (bytes).