bloom

package
v1.11.8 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package bloom implements process-local probabilistic membership filters. Callers must account for false positives and provide external persistence or coordination when filters are shared across application instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CountMinSketch

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

CountMinSketch implements frequency estimation for top-K trending items.

func NewCountMinSketch

func NewCountMinSketch() *CountMinSketch

NewCountMinSketch creates a Count-Min Sketch frequency estimator.

func (*CountMinSketch) Add

func (cms *CountMinSketch) Add(item string, count uint64)

Add increments the frequency count for an item.

func (*CountMinSketch) EstimateFrequency

func (cms *CountMinSketch) EstimateFrequency(item string) uint64

EstimateFrequency estimates the total frequency count of an item.

type Filter

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

Filter implements a high-performance Bloom Filter for preventing cache penetration attacks.

func NewFilter

func NewFilter(capacity uint64, fpRate float64) *Filter

NewFilter creates a new Bloom Filter tuned for expected capacity and false positive rate.

func (*Filter) Add

func (f *Filter) Add(key string)

Add inserts a key into the Bloom Filter.

func (*Filter) MayContain

func (f *Filter) MayContain(key string) bool

MayContain tests if key is possibly in the set. If it returns false, the key 100% does NOT exist!

type HyperLogLog

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

HyperLogLog implements probabilistic cardinality counting for unique visitors in constant memory.

func NewHyperLogLog

func NewHyperLogLog() *HyperLogLog

NewHyperLogLog creates a HyperLogLog cardinality counter.

func (*HyperLogLog) Add

func (hll *HyperLogLog) Add(element string)

Add adds an element to the HyperLogLog set.

func (*HyperLogLog) EstimateCardinality

func (hll *HyperLogLog) EstimateCardinality() uint64

EstimateCardinality returns the estimated count of unique elements.

Jump to

Keyboard shortcuts

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