Help us shape the future of Go! Take the 2026 Go Developer Survey

hyperloglog

package module
v0.0.0-...-9990f20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 3 Imported by: 0

README

Implements the HyperLogLog algorithm.

HyperLogLog paper: http://algo.inria.fr/flajolet/Publications/FlFuGaMe07.pdf

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

View Source
const (
	PrecisionMin = 4
	PrecisionMax = 16
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash32

type Hash32 interface {
	Sum32() uint32
}

type HyperLogLog

type HyperLogLog struct {
	// contains filtered or unexported fields
}

func New

func New(precision int) (*HyperLogLog, error)

New returns a new initialized HyperLogLog.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL