Documentation
¶
Overview ¶
Package hyperloglog implements the HyperLogLog and HyperLogLog++ cardinality estimation algorithms. These algorithms are used for accurately estimating the cardinality of a multiset using constant memory. HyperLogLog++ has multiple improvements over HyperLogLog, with a much lower error rate for smaller cardinalities.
HyperLogLog is described here: http://algo.inria.fr/flajolet/Publications/FlFuGaMe07.pdf
HyperLogLog++ is described here: http://research.google.com/pubs/pub40671.html
Index ¶
Constants ¶
const ( PrecisionMin = 4 PrecisionMax = 16 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HyperLogLog ¶
type HyperLogLog struct {
// contains filtered or unexported fields
}
func NewReg ¶
func NewReg(reg []uint8) (*HyperLogLog, error)
NewReg creates HyperLogLog, which uses passed array as registers.
func (*HyperLogLog) Add ¶
func (h *HyperLogLog) Add(item Hash32) bool
Add adds a new item to HyperLogLog h.
func (*HyperLogLog) Clear ¶
func (h *HyperLogLog) Clear()
Clear sets HyperLogLog h back to its initial state.
func (*HyperLogLog) Copy ¶
func (h *HyperLogLog) Copy() *HyperLogLog
Copy returns copy of HyperLogLog.
func (*HyperLogLog) Count ¶
func (h *HyperLogLog) Count() uint64
func (*HyperLogLog) Merge ¶
func (h *HyperLogLog) Merge(other *HyperLogLog) (bool, error)
Merge takes another HyperLogLog and combines it with HyperLogLog h. Returns whether h has changed after merge along with an error, which cal only occur if sizes of HLLs are different.
func (*HyperLogLog) Precision ¶
func (h *HyperLogLog) Precision() int
func (*HyperLogLog) Registers ¶
func (h *HyperLogLog) Registers() []uint8
Registers returns raw registers of HyperLogLog.