bloomfilter

package
v0.0.0-debug-20260702 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 15 Imported by: ? modules, 0 packages

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.

Documentation

Index

Constants

View Source
const MAX_K_SEED = 64

MAX_K_SEED is the maximum number of hash functions allowed by the C implementation.

Variables

This section is empty.

Functions

func ComputeMemAndHashCountC

func ComputeMemAndHashCountC(rowCount int64, probability float64) (uint64, uint32)

Types

type BloomFilter

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

BloomFilter is a handle to the bloom filter data. It contains private scratch buffers to allow concurrent testing without locking.

func New

func New(rowCount int64, probability float64) BloomFilter

func (*BloomFilter) Add

func (bf *BloomFilter) Add(v *vector.Vector)

func (*BloomFilter) Clean

func (bf *BloomFilter) Clean()

Clean releases all resources of the bloom filter.

func (*BloomFilter) Free

func (bf *BloomFilter) Free()

Free decrements the reference count of the shared data and cleans up if it reaches zero.

func (*BloomFilter) Marshal

func (bf *BloomFilter) Marshal() ([]byte, error)

Marshal encodes BloomFilter into byte sequence.

func (*BloomFilter) NewHandle

func (bf *BloomFilter) NewHandle() *BloomFilter

NewHandle creates a new BloomFilter handle that shares the underlying data but has its own scratch buffers for thread-safe concurrent testing.

func (*BloomFilter) Reset

func (bf *BloomFilter) Reset()

func (*BloomFilter) Test

func (bf *BloomFilter) Test(v *vector.Vector, callBack func(bool, int))

func (*BloomFilter) TestAndAdd

func (bf *BloomFilter) TestAndAdd(v *vector.Vector, callBack func(bool, int))

func (*BloomFilter) TestRow

func (bf *BloomFilter) TestRow(v *vector.Vector, row int) bool

TestRow tests if a single row might be in the bloom filter.

func (*BloomFilter) Unmarshal

func (bf *BloomFilter) Unmarshal(data []byte) error

Unmarshal restores BloomFilter from byte sequence and initializes internal handles.

func (*BloomFilter) Valid

func (bf *BloomFilter) Valid() bool

Valid returns true if the BloomFilter is initialized and usable.

type CBloomFilter

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

CBloomFilter is a wrapper around the C implementation of a bloom filter.

func NewCBloomFilter

func NewCBloomFilter(nbits uint64, k uint32) *CBloomFilter

NewCBloomFilter creates a new CBloomFilter with a specific number of bits (nbits) and number of hash functions (k).

func NewCBloomFilterWithProbability

func NewCBloomFilterWithProbability(rowcnt int64, probability float64) *CBloomFilter

NewCBloomFilterWithProbaility creates a new CBloomFilter with optimal parameters derived from the expected number of elements (rowcnt) and the desired false positive probability.

func NewCBloomFilterWithSeed

func NewCBloomFilterWithSeed(nbits uint64, k uint32, seed uint64) *CBloomFilter

NewCBloomFilterWithSeed creates a new CBloomFilter with a specific number of bits (nbits), number of hash functions (k), and a specific seed.

func (*CBloomFilter) Add

func (bf *CBloomFilter) Add(data []byte)

Add inserts a byte slice into the bloom filter.

func (*CBloomFilter) AddVector

func (bf *CBloomFilter) AddVector(v *vector.Vector)

AddVector adds all elements in the vector to the bloom filter.

func (*CBloomFilter) Exact

func (bf *CBloomFilter) Exact() bool

Exact reports whether membership is exact. A bloom filter is approximate (it has false positives), so this is always false. It lets CBloomFilter satisfy the engine.MembershipFilter interface alongside the exact bitset filters.

func (*CBloomFilter) Free

func (bf *CBloomFilter) Free()

Free releases the C memory allocated for the bloom filter.

func (*CBloomFilter) GetK

func (bf *CBloomFilter) GetK() uint32

func (*CBloomFilter) GetNbits

func (bf *CBloomFilter) GetNbits() uint64

func (*CBloomFilter) GetSeed

func (bf *CBloomFilter) GetSeed() uint64

func (*CBloomFilter) Marshal

func (bf *CBloomFilter) Marshal() ([]byte, error)

Marshal serializes the bloom filter into a byte slice.

func (*CBloomFilter) Merge

func (bf *CBloomFilter) Merge(other *CBloomFilter) error

Merge merges another bloom filter into this one (bf becomes bf OR other). The nbits, seed, and k MUST be the same for both bloom filters.

func (*CBloomFilter) Ptr

func (bf *CBloomFilter) Ptr() *C.bloomfilter_t

func (*CBloomFilter) SharePointer

func (bf *CBloomFilter) SharePointer() *CBloomFilter

Share the CBloomfilter and increment the reference counter

func (*CBloomFilter) Test

func (bf *CBloomFilter) Test(data []byte) bool

Test checks if a byte slice is possibly in the bloom filter.

func (*CBloomFilter) TestAndAdd

func (bf *CBloomFilter) TestAndAdd(data []byte) bool

TestAndAdd checks if a byte slice is in the bloom filter and adds it if it's not.

func (*CBloomFilter) TestAndAddVector

func (bf *CBloomFilter) TestAndAddVector(v *vector.Vector, callBack func(bool, bool, int))

TestAndAddVector tests and adds all elements in the vector to the bloom filter. It invokes the callback function for all elements in the vector.

func (*CBloomFilter) TestVector

func (bf *CBloomFilter) TestVector(v *vector.Vector, callBack func(bool, bool, int)) []uint8

TestVector tests all elements in the vector against the bloom filter. It invokes the callback function for all elements in the vector.

func (*CBloomFilter) Unmarshal

func (bf *CBloomFilter) Unmarshal(data []byte) error

Unmarshal reconstructs the bloom filter from a byte slice.

func (*CBloomFilter) Valid

func (bf *CBloomFilter) Valid() bool

Check CBloomFilter is Valid

Jump to

Keyboard shortcuts

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