Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BloomFilter ¶
type BloomFilter struct { NumBits uint32 `json:"numBits"` // number of bits in filter NumIdx uint8 `json:"numIdx"` // number of indices NumIdxBits uint8 `json:"numIdxBits"` // number of bits per index NumHash uint8 `json:"numHash"` // number of SHA256 hashes needed Bits []byte `json:"bits" size:"*"` // bit storage }
A BloomFilter is a space/time efficient set of unique entries. It can not enumerate its elements, but can check if an entry is contained in the set. The check always succeeds for a contained entry, but can create "false-positives" (entries not contained in the map give a positive result). By adjusting the number of bits in the BloomFilter and the number of indices generated for an entry, a BloomFilter can handle a given number of entries with a desired upper-bound for the false-positive rate.
func NewBloomFilter ¶
func NewBloomFilter(numExpected int, falsePositiveRate float64) *BloomFilter
NewBloomFilter creates a new BloomFilter based on the upper-bounds for the number of entries and the "false-positive" rate.
func NewBloomFilterDirect ¶
func NewBloomFilterDirect(numBits, numIdx int) *BloomFilter
NewBloomFilterDirect creates a new BloomFilter based on the number of bits in the filter and the number of indices to be used.
func (*BloomFilter) Combine ¶
func (bf *BloomFilter) Combine(bf2 *BloomFilter) *BloomFilter
Combine merges two BloomFilters (of same kind) into a new one.
func (*BloomFilter) Contains ¶
func (bf *BloomFilter) Contains(entry []byte) bool
Contains returns true if the BloomFilter contains the given entry, and false otherwise. If an entry was added to the set, this function will always return 'true'. It can return 'true' for entries not in the set ("false-positives").
func (*BloomFilter) SameKind ¶
func (bf *BloomFilter) SameKind(bf2 *BloomFilter) bool
SameKind checks if two BloomFilter have the same parameters.