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
deprecated
type HLL struct {
// contains filtered or unexported fields
}
An HLL is a HyperLogLog counter for arbitrary values.
Deprecated: use HLL2.
func (*HLL) AddHLL ¶
AddHLL adds the state of another counter to h. The result is equivalent to adding all the values of other to h.
func (*HLL) ApproxCount ¶
ApproxCount returns the current approximate count. Does not alter the state of the counter.
func (*HLL) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*HLL) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type HLL2 ¶ added in v0.1.17
type HLL2[T any] struct { // contains filtered or unexported fields }
An HLL2 is a HyperLogLog counter for arbitrary values.
func New2 ¶ added in v0.1.17
New2 creates a new HyperLogLog counter. The counter will use 2^logSize bytes. h is the hash function to use for added values.
func (*HLL2[T]) Add ¶ added in v0.1.17
func (h *HLL2[T]) Add(t T)
Add adds v to the counter. Calls hash once.
func (*HLL2[T]) AddHLL ¶ added in v0.1.17
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 (*HLL2[T]) ApproxCount ¶ added in v0.1.17
ApproxCount returns the current approximate count. Does not alter the state of the counter.