Documentation
¶
Overview ¶
Package hll provides a HyperLogLog probabilistic cardinality estimator.
NOT safe for concurrent use. Callers must synchronize access externally.
Index ¶
- Constants
- Variables
- func GetBytes(key interface{}) ([]byte, error)
- type HyperLogLog
- func (h *HyperLogLog) Add(data []byte)
- func (h *HyperLogLog) AddAny(data any) error
- func (h *HyperLogLog) Clear() error
- func (h *HyperLogLog) Count() uint64
- func (h *HyperLogLog) IntersectionCount(h2 *HyperLogLog) (uint64, error)
- func (h *HyperLogLog) Len() int
- func (h *HyperLogLog) MarshalBinary() ([]byte, error)
- func (h *HyperLogLog) ToBytes() []byte
- func (h *HyperLogLog) Union(h2 *HyperLogLog) (*HyperLogLog, error)
- func (h *HyperLogLog) UnionCount(h2 *HyperLogLog) (uint64, error)
- func (h *HyperLogLog) UnmarshalBinary(data []byte) error
Constants ¶
const ( DefaultLog2m = 31 DefaultRegwidth = 8 )
HyperLogLog configuration constants.
Variables ¶
var DefaultSettings = hll.Settings{ Log2m: DefaultLog2m, Regwidth: DefaultRegwidth, ExplicitThreshold: hll.AutoExplicitThreshold, SparseEnabled: true, }
DefaultSettings is the default HyperLogLog configuration used by New.
Functions ¶
Types ¶
type HyperLogLog ¶
HyperLogLog is a probabilistic cardinality estimator.
func FromBytes ¶
func FromBytes(raw []byte) (*HyperLogLog, error)
FromBytes deserializes a HyperLogLog from its binary representation.
func (*HyperLogLog) Add ¶
func (h *HyperLogLog) Add(data []byte)
Add hashes the given byte slice and adds it to the HyperLogLog.
func (*HyperLogLog) AddAny ¶
func (h *HyperLogLog) AddAny(data any) error
AddAny gob-encodes the given value and adds it to the HyperLogLog.
func (*HyperLogLog) Clear ¶
func (h *HyperLogLog) Clear() error
Clear resets the HyperLogLog to an empty state.
func (*HyperLogLog) Count ¶
func (h *HyperLogLog) Count() uint64
Count returns the estimated number of distinct items as a uint64.
func (*HyperLogLog) IntersectionCount ¶
func (h *HyperLogLog) IntersectionCount(h2 *HyperLogLog) (uint64, error)
IntersectionCount estimates the number of distinct items common to h and h2 using inclusion-exclusion.
func (*HyperLogLog) Len ¶
func (h *HyperLogLog) Len() int
Len returns the estimated number of distinct items in the set.
func (*HyperLogLog) MarshalBinary ¶
func (h *HyperLogLog) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*HyperLogLog) ToBytes ¶
func (h *HyperLogLog) ToBytes() []byte
ToBytes serializes the HyperLogLog into its binary representation.
func (*HyperLogLog) Union ¶
func (h *HyperLogLog) Union(h2 *HyperLogLog) (*HyperLogLog, error)
Union returns a new HyperLogLog that is the union of h and h2.
func (*HyperLogLog) UnionCount ¶
func (h *HyperLogLog) UnionCount(h2 *HyperLogLog) (uint64, error)
UnionCount returns the estimated cardinality of the union of h and h2.
func (*HyperLogLog) UnmarshalBinary ¶
func (h *HyperLogLog) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.