hllplus

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MinPrecision       = 10
	MaxPrecision       = 24
	MaxSparsePrecision = 25
)

Precision bounds.

Variables

This section is empty.

Functions

This section is empty.

Types

type HLL

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

HLL is a HyperLogLog++ sketch implementation.

func New

func New(precision, sparsePrecision uint8) (*HLL, error)

New inits a new sketch. The normal precision must be between 10 and 24. The sparse precision must be between 0 and 25. This function only returns an error when an invalid precision is provided.

func NewFromProto

func NewFromProto(msg *pb.HyperLogLogPlusUniqueStateProto) (*HLL, error)

NewFromProto inits/restores a sketch from proto message.

func (*HLL) Add

func (s *HLL) Add(hash uint64)

Add adds the uniform hash value to the representation.

func (*HLL) Clone

func (s *HLL) Clone() *HLL

Clone creates a copy of the sketch.

func (*HLL) Downgrade

func (s *HLL) Downgrade(precision, sparsePrecision uint8) error

Downgrade tries to reduce the precision of the sketch. Attempts to increase precision will be ignored.

func (*HLL) Estimate

func (s *HLL) Estimate() int64

Estimate computes the cardinality estimate according to the algorithm in Figure 6 of the HLL++ paper (https://goo.gl/pc916Z).

func (*HLL) Merge

func (s *HLL) Merge(other *HLL)

Merge merges other into s.

func (*HLL) Precision

func (s *HLL) Precision() uint8

Precision returns the normal precision.

func (*HLL) Proto

Proto builds a BigQuery-compatible protobuf message, representing HLL aggregator state.

func (*HLL) SparsePrecision

func (s *HLL) SparsePrecision() uint8

SparsePrecision returns the sparse precision.

Jump to

Keyboard shortcuts

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