hyperloglog

package module
v0.0.0-...-8d94b4e Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 9 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

CircleCI

Fork from original Axiom's HyperLogLog with serializing features.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorTooShort = errors.New("too short binary")

ErrorTooShort is an error that UnmarshalBinary try to parse too short binary.

Functions

This section is empty.

Types

type Sketch

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

Sketch is a HyperLogLog data-structure for the count-distinct problem, approximating the number of distinct elements in a multiset.

func DeSerialize

func DeSerialize(data []byte) (*Sketch, error)

func New

func New() *Sketch

New returns a HyperLogLog Sketch with 2^14 registers (precision 14)

func New14

func New14() *Sketch

New14 returns a HyperLogLog Sketch with 2^14 registers (precision 14)

func New16

func New16() *Sketch

New16 returns a HyperLogLog Sketch with 2^16 registers (precision 16)

func New16NoSparse

func New16NoSparse() *Sketch

New16NoSparse returns a HyperLogLog Sketch with 2^16 registers (precision 16) that will not use a sparse representation

func NewNoSparse

func NewNoSparse() *Sketch

NewNoSparse returns a HyperLogLog Sketch with 2^14 registers (precision 14) that will not use a sparse representation

func (*Sketch) Clone

func (sk *Sketch) Clone() *Sketch

Clone returns a deep copy of sk.

func (*Sketch) Estimate

func (sk *Sketch) Estimate() uint64

Estimate returns the cardinality of the Sketch

func (*Sketch) Insert

func (sk *Sketch) Insert(e []byte) bool

Insert adds element e to sketch

func (*Sketch) InsertHash

func (sk *Sketch) InsertHash(x uint64) bool

InsertHash adds hash x to sketch

func (*Sketch) MarshalBinary

func (sk *Sketch) MarshalBinary() (data []byte, err error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*Sketch) Merge

func (sk *Sketch) Merge(other *Sketch) error

Merge takes another Sketch and combines it with Sketch h. If Sketch h is using the sparse Sketch, it will be converted to the normal Sketch.

func (*Sketch) Serialize

func (sk *Sketch) Serialize() ([]byte, error)

func (*Sketch) UnmarshalBinary

func (sk *Sketch) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

type SketchOps

type SketchOps struct {
	P          uint8
	B          uint8
	M          uint32
	Alpha      float64
	TmpSet     map[uint32]struct{}
	SparseList *struct {
		Count uint32
		Last  uint32
		B     []uint8
	}
	Regs *struct {
		T  []reg
		NZ uint32
	}
}

Jump to

Keyboard shortcuts

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