Documentation
¶
Overview ¶
Package bloom provides a bloom filter.
Index ¶
Constants ¶
const ( // Version is the version number of the binary serialization format. All // prior versions up to and including this one are deserializable by this // package. Version = 1 )
Variables ¶
var ErrIncompatibleVersion = errors.New("bloom: incompatible version")
Functions ¶
Types ¶
type Bloom ¶
type Bloom struct {
// contains filtered or unexported fields
}
Bloom is a bloom filter which can be used to probabilisticly test whether an item is a member of a set. False positives are possible but false negatives are not. Items may be added but cannot be removed from the set.
func New ¶
New creates a new bloom filter suitable for storing n items with a false positive rate of p.
func WithBytes ¶
WithBytes creates a new bloom filter that uses buf as its backing storage, preserving any existing data in the byte slice. Any subsequent writes to the bloom filter will mutate buf. The layout of the byte buffer must match the layout used by the WriteTo method.
func (*Bloom) Count ¶
Count returns an estimate of the number of items that have been added to the bloom filter.
func (*Bloom) ErrorRate ¶
ErrorRate returns an estimate of the rate of false positives returned by the bloom filter's Has method.
func (*Bloom) Has ¶
Has reports whether v is possibly present in the bloom filter. If false then the item is definitely not in the set.
func (*Bloom) ReadFrom ¶
ReadFrom reads a binary representation of the bloom filter from r overwriting any previous configuration. It adheres to the io.ReaderFrom interface protocol. It reads data from r until EOF or error. The return value n is the number of bytes read. Any error except io.EOF encountered during the read is also returned.