Documentation ¶
Overview ¶
Package hll contains a HyperLogLog++ with a LogLog-Beta bias correction implementation that is adapted (mostly copied) from an implementation provided by Clark DuVall github.com/clarkduvall/hyperloglog.
The differences are that the implementation in this package:
- uses an AMD64 optimised xxhash algorithm instead of murmur;
- uses some AMD64 optimisations for things like clz;
- works with []byte rather than a Hash64 interface, to reduce allocations;
- implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler
Based on some rough benchmarking, this implementation of HyperLogLog++ is around twice as fast as the github.com/clarkduvall/hyperloglog implementation.
Index ¶
Constants ¶
const DefaultPrecision = 16
DefaultPrecision is the default precision.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Plus ¶
type Plus struct {
// contains filtered or unexported fields
}
Plus implements the Hyperloglog++ algorithm, described in the following paper: http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/40671.pdf
The HyperLogLog++ algorithm provides cardinality estimations.
func MustNewPlus ¶
MustNewPlus returns a new Plus with precision p. Panic on error.
func NewDefaultPlus ¶
func NewDefaultPlus() *Plus
NewDefaultPlus creates a new Plus with the default precision.
func (*Plus) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*Plus) Merge ¶
Merge takes another HyperLogLogPlus and combines it with HyperLogLogPlus h. If HyperLogLogPlus h is using the sparse representation, it will be converted to the normal representation.
func (*Plus) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.