Documentation ¶
Index ¶
- func WriteFilter(filter *BloomFilter, path string, gzip bool) error
- type BloomFilter
- func (s *BloomFilter) Add(value []byte)
- func (s *BloomFilter) Check(value []byte) bool
- func (s *BloomFilter) CheckFingerprint(fingerprint []uint64) bool
- func (s *BloomFilter) FalsePositiveProb() float64
- func (s *BloomFilter) Fingerprint(value []byte, fingerprint []uint64)
- func (s *BloomFilter) Join(s2 *BloomFilter) error
- func (s *BloomFilter) MaxNumElements() uint64
- func (s *BloomFilter) NumBits() uint64
- func (s *BloomFilter) NumHashFuncs() uint64
- func (s *BloomFilter) Read(input io.Reader) error
- func (s *BloomFilter) Reset()
- func (s *BloomFilter) Write(output io.Writer) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteFilter ¶
func WriteFilter(filter *BloomFilter, path string, gzip bool) error
WriteFilter writes a binary Bloom filter representation for a given struct to a file. If 'gzip' is true, then a compressed file will be written.
Types ¶
type BloomFilter ¶
type BloomFilter struct { //number of elements in the filter N uint64 //number of 64-bit integers (generated automatically) M uint64 //arbitrary data that we can attach to the filter Data []byte // contains filtered or unexported fields }
BloomFilter represents a Bloom filter, a data structure for quickly checking for set membership, with a specific desired capacity and false positive probability.
func Initialize ¶
func Initialize(n uint64, p float64) BloomFilter
Initialize returns a new, empty Bloom filter with the given capacity (n) and FP probability (p).
func LoadFilter ¶
func LoadFilter(path string, gzip bool) (*BloomFilter, error)
LoadFilter reads a binary Bloom filter representation from a file and returns a BloomFilter struct pointer based on it. If 'gzip' is true, then compressed input will be expected.
func LoadFromBytes ¶ added in v0.2.0
func LoadFromBytes(input []byte, gzip bool) (*BloomFilter, error)
LoadFromBytes reads a binary Bloom filter representation from a byte array and returns a BloomFilter struct pointer based on it. If 'gzip' is true, then compressed input will be expected.
func LoadFromReader ¶ added in v0.2.0
func LoadFromReader(inReader io.Reader, gzip bool) (*BloomFilter, error)
LoadFromReader reads a binary Bloom filter representation from an io.Reader and returns a BloomFilter struct pointer based on it. If 'gzip' is true, then compressed input will be expected.
func (*BloomFilter) Add ¶
func (s *BloomFilter) Add(value []byte)
Add adds a byte array element to the Bloom filter.
func (*BloomFilter) Check ¶
func (s *BloomFilter) Check(value []byte) bool
Check returns true if the given value may be in the Bloom filter, false if it is definitely not in it.
func (*BloomFilter) CheckFingerprint ¶
func (s *BloomFilter) CheckFingerprint(fingerprint []uint64) bool
CheckFingerprint returns true if the given fingerprint occurs in the Bloom filter, false if it does not.
func (*BloomFilter) FalsePositiveProb ¶ added in v0.2.0
func (s *BloomFilter) FalsePositiveProb() float64
FalsePositiveProb returns the chosen false positive probability for the Bloom filter.
func (*BloomFilter) Fingerprint ¶
func (s *BloomFilter) Fingerprint(value []byte, fingerprint []uint64)
Fingerprint returns the fingerprint of a given value, as an array of index values.
func (*BloomFilter) Join ¶ added in v0.2.0
func (s *BloomFilter) Join(s2 *BloomFilter) error
Join adds the items of another Bloom filter with identical dimensions to the receiver. That is, all elements that are described in the second filter will also described by the receiver, and the number of elements of the receiver will grow by the number of elements in the added filter. Note that it is implicitly assumed that both filters are disjoint! Otherwise the number of elements in the joined filter must _only_ be considered an upper bound and not an exact value! Joining two differently dimensioned filters may yield unexpected results and hence is not allowed. An error will be returned in this case, and the receiver will be left unaltered.
func (*BloomFilter) MaxNumElements ¶ added in v0.2.0
func (s *BloomFilter) MaxNumElements() uint64
MaxNumElements returns the maximal supported number of elements in the Bloom filter (capacity).
func (*BloomFilter) NumBits ¶ added in v0.2.0
func (s *BloomFilter) NumBits() uint64
NumBits returns the number of bits used in the Bloom filter.
func (*BloomFilter) NumHashFuncs ¶ added in v0.2.0
func (s *BloomFilter) NumHashFuncs() uint64
NumHashFuncs returns the number of hash functions used in the Bloom filter.
func (*BloomFilter) Read ¶
func (s *BloomFilter) Read(input io.Reader) error
Read loads a filter from a reader object.
func (*BloomFilter) Reset ¶
func (s *BloomFilter) Reset()
Reset clears the Bloom filter of all elements.