count

package
v0.1.0-RC1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PreambleLongsShort = 2
	SerialVersion1     = 1
	Null8              = 0
	Null32             = 0
	IsEmpty            = 0
)

Variables

This section is empty.

Functions

func Min

func Min[T constraints.Ordered](a, b T) T

func SuggestNumBuckets

func SuggestNumBuckets(relativeError float64) (int32, error)

func SuggestNumHashes

func SuggestNumHashes(confidence float64) (int8, error)

Types

type CountMinSketch

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

Implementation of the CountMin sketch data structure of Cormode and Muthukrishnan. [1] - http://dimacs.rutgers.edu/~graham/pubs/papers/cm-full.pdf

func NewCountMinSketch

func NewCountMinSketch(numHashes int8, numBuckets int32, seed int64) (*CountMinSketch, error)

NewCountMinSketch creates an instance of the CounrMin sketch given parameters numHashes, numBuckets and hash seed. The items inserted into the sketch can be arbitrary type, so long as they are hashable via murmurhash. Only update and estimate methods are added for uint64 and string types.

func (*CountMinSketch) Deserialize

func (c *CountMinSketch) Deserialize(b []byte, seed int64) (*CountMinSketch, error)

func (*CountMinSketch) GetEstimate

func (c *CountMinSketch) GetEstimate(item []byte) int64

func (*CountMinSketch) GetEstimateString

func (c *CountMinSketch) GetEstimateString(item string) int64

func (*CountMinSketch) GetEstimateUint64

func (c *CountMinSketch) GetEstimateUint64(item uint64) int64

func (*CountMinSketch) GetLowerBound

func (c *CountMinSketch) GetLowerBound(item []byte) int64

func (*CountMinSketch) GetLowerBoundUint64

func (c *CountMinSketch) GetLowerBoundUint64(item uint64) int64

func (*CountMinSketch) GetNumBuckets

func (c *CountMinSketch) GetNumBuckets() int32

func (*CountMinSketch) GetNumHashes

func (c *CountMinSketch) GetNumHashes() int8

func (*CountMinSketch) GetRelativeError

func (c *CountMinSketch) GetRelativeError() float64

func (*CountMinSketch) GetSeed

func (c *CountMinSketch) GetSeed() int64

func (*CountMinSketch) GetTotalWeight

func (c *CountMinSketch) GetTotalWeight() int64

func (*CountMinSketch) GetUpperBound

func (c *CountMinSketch) GetUpperBound(item []byte) int64

func (*CountMinSketch) GetUpperBoundUint64

func (c *CountMinSketch) GetUpperBoundUint64(item uint64) int64

func (*CountMinSketch) Merge

func (c *CountMinSketch) Merge(otherSketch *CountMinSketch) error

func (*CountMinSketch) Serialize

func (c *CountMinSketch) Serialize(w io.Writer) error

func (*CountMinSketch) Update

func (c *CountMinSketch) Update(item []byte, weight int64) error

func (*CountMinSketch) UpdateString

func (c *CountMinSketch) UpdateString(item string, weight int64) error

func (*CountMinSketch) UpdateUint64

func (c *CountMinSketch) UpdateUint64(item uint64, weight int64) error

Jump to

Keyboard shortcuts

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