filter

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BloomFilter

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

BloomFilter implements a thread-safe Bloom Filter for high-speed deduplication.

func NewBloomFilter

func NewBloomFilter(m, k uint) *BloomFilter

NewBloomFilter creates a new Bloom Filter with m bits and k hash functions.

func (*BloomFilter) Add

func (f *BloomFilter) Add(data []byte)

Add adds data to the filter.

func (*BloomFilter) Reset

func (f *BloomFilter) Reset()

Reset clears the filter.

func (*BloomFilter) Test

func (f *BloomFilter) Test(data []byte) bool

Test returns true if data might be in the filter.

type Filter

type Filter interface {
	Add(data []byte)
	Test(data []byte) bool
	Reset()
}

Filter defines a generic interface for probabilistic data filters.

type RotatingBloomFilter

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

RotatingBloomFilter uses two Bloom Filters to provide a sliding window of deduplication.

func NewRotatingBloomFilter

func NewRotatingBloomFilter(m, k, limit uint) *RotatingBloomFilter

NewRotatingBloomFilter creates a new RotatingBloomFilter that rotates after limit additions.

func (*RotatingBloomFilter) Add

func (f *RotatingBloomFilter) Add(data []byte)

Add adds data to the current filter and rotates if limit is reached.

func (*RotatingBloomFilter) Reset

func (f *RotatingBloomFilter) Reset()

Reset clears both filters.

func (*RotatingBloomFilter) Test

func (f *RotatingBloomFilter) Test(data []byte) bool

Test checks both current and previous filters.

Jump to

Keyboard shortcuts

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