A Bloom filter is a space-efficient probabilistic data structure used to test whether an element is a member of a set. It can quickly indicate if an item is definitely not in the set or possibly in the set, but it may produce false positives. Blossom implements several Bloom filters. All use the FNV Hash function and the optimization described by Kirsch and Mitzenmacher.

Classes

AttenuatedBloomFilter
BloomFilter
SafeBloomFilter
ScalingBloomFilter

Methods

(static) calculateSize(capacity, errorRate) → {number}

Determines the appropriate size attribute given a capacity and error rate.

Parameters:
NameTypeDescription
capacitynumber

Capacity of a Bloom filter

errorRatenumber

Acceptable error ratio for filter

Returns:
Type: 
number

(inner) calculateSlices(size, capacity) → {number}

Determines how many slices the filter should use for hashing.

Parameters:
NameTypeDescription
sizenumber

Size of the underlying module:blossom/bitfield~Bitfield

capacitynumber

Capacity of a Bloom filter

Returns:
Type: 
number

(inner) calulateHashes(key, size, slices) → {Array.<number>}

Calculates the hashes for an item in a Bloom filter.

Parameters:
NameTypeDescription
keystring | Buffer

The item to hash

sizenumber

The size of the resulting hash

slicesnumber

Total slices to use for hashing

Returns:
Type: 
Array.<number>