Documentation
¶
Overview ¶
Package hll provides an implementation of the HyperLogLog algorithm.
A HyperLogLog counter can approximate the cardinality of a set with high accuracy and little memory.
Accuracy ¶
Average error for 1,000,000,000 elements for different values of logSize:
logSize average error % 4 21 5 12 6 10 7 8.1 8 4.8 9 3.6 10 1.9 11 1.2 12 1.0 13 0.7 14 0.5 15 0.33 16 0.25
Citation ¶
Flajolet, Philippe; Fusy, Éric; Gandouet, Olivier; Meunier, Frédéric (2007). "Hyperloglog: The analysis of a near-optimal cardinality estimation algorithm". Discrete Mathematics and Theoretical Computer Science Proceedings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HLL ¶
type HLL[T any] struct { // contains filtered or unexported fields }
An HLL is a HyperLogLog counter for arbitrary values.
func New ¶
New creates a new HyperLogLog counter. The counter will use 2^logSize bytes. h is the hash function to use for added values.
func (*HLL[T]) AddHLL ¶
AddHLL adds the state of another counter to h, assuming they use the same hash function. The result is equivalent to adding all the values of other to h.
func (*HLL[T]) ApproxCount ¶
ApproxCount returns the current approximate count. Does not alter the state of the counter.