Documentation ¶
Overview ¶
Package bloomfilter implemented with SHA1 for hashing.
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 is implemented using the bitset package.
func NewBloomFilter ¶
func NewBloomFilter(n uint32) *BloomFilter
NewBloomFilter will construct a new BloomFilter intended to model n bits. The BitSet constructor will round that number up to the next byte boundary. The BitSet should be adequately compact. Values written into the bloom filter will use modulo to determine the index to set...meaning, overflow indexes will wrap. The BitSet is already concurrent safe through the use of RWMutex. Note: each entry into the filter sets five values, so having n below be less than five is nonsensical
func (*BloomFilter) Read ¶
func (b *BloomFilter) Read(sha1Ints SHA1Ints) (FilterVals, bool, error)
Read the filter values for the modulo offsets for the SHA1Ints, and also send back a convenience bool to indicate if they were all true or not
func (*BloomFilter) Size ¶
func (b *BloomFilter) Size() int
Size will return the size of the underlying BitSet. May be greater than the arg provided to the constructor...the BitSet package rounds up to a byte boundary.
func (*BloomFilter) Write ¶
func (b *BloomFilter) Write(sha1Ints SHA1Ints) (bool, error)
Write shall enter a true (1) value into the underlying BitSet at the modulo offsets described by the sha1Ints (five 32-bit ints). Returns a boolean indicating if there was a collision in the filter (meaning all indexes to be set were already set to true)
type FilterVals ¶
type FilterVals [5]bool
FilterVals are filter values corresponding to offsets derived from the SHA1-ints.