bloom_filter_mod module

Bloom Filter: Probabilistic set membership testing for large sets.

class bloom_filter_mod.Array_backend(num_bits)[source]

Bases: object

Backend storage for our “array of bits” using a python array of integers.

clear(bitno)[source]

Clear bit number bitno - set it to false.

close()[source]

Noop for compatibility with the file+seek backend.

effs = 4294967295
is_set(bitno)[source]

Return true iff bit number bitno is set.

set(bitno)[source]

Set bit number bitno to true.

class bloom_filter_mod.Array_then_file_seek_backend(num_bits, filename, max_bytes_in_memory)[source]

Bases: object

Backend storage for our “array of bits” using a python array of integers up to some maximum number of bytes…

…then spilling over to a file. This is -not- a cache; we instead save the leftmost bits in RAM, and the rightmost bits (if necessary) in a file. On open, we read from the file to RAM. On close, we write from RAM to the file.

clear(bitno)[source]

Clear bit number bitno - set it to false.

close()[source]

Write the in-memory portion to disk, leave the already-on-disk portion unchanged.

effs = 255
is_set(bitno)[source]

Return true iff bit number bitno is set.

set(bitno)[source]

Set bit number bitno to true.

class bloom_filter_mod.Bloom_filter(ideal_num_elements_n, error_rate_p, probe_bitnoer=<function get_bitno_lin_comb>, filename=None, start_fresh=False)[source]

Bases: object

Probabilistic set membership testing for large sets.

add(key)[source]

Add an element to the filter.

intersection(bloom_filter)[source]

Compute the set intersection of two bloom filters.

union(bloom_filter)[source]

Compute the set union of two bloom filters.

class bloom_filter_mod.File_seek_backend(num_bits, filename)[source]

Bases: object

Backend storage for our “array of bits” using a file in which we seek.

clear(bitno)[source]

Clear bit number bitno - set it to false.

close()[source]

Close the file.

effs = 5
is_set(bitno)[source]

Return true iff bit number bitno is set.

set(bitno)[source]

Set bit number bitno to true.

class bloom_filter_mod.Mmap_backend(num_bits, filename)[source]

Bases: object

Backend storage for our “array of bits” using an mmap’d file.

Please note that this has only been tested on Linux so far: 2 -11-01.

clear(bitno)[source]

Clear bit number bitno - set it to false.

close()[source]

Close the file.

effs = 5
is_set(bitno)[source]

Return true iff bit number bitno is set.

set(bitno)[source]

Set bit number bitno to true.

bloom_filter_mod.get_bitno_lin_comb(bloom_filter, key)[source]

Apply num_probes_k hash functions to key. Generate the array index and bitmask corresponding to each result.

bloom_filter_mod.get_bitno_seed_rnd(bloom_filter, key)[source]

Apply num_probes_k hash functions to key. Generate the array index and bitmask corresponding to each result.

bloom_filter_mod.hash1(int_list)[source]

Hash input: function #1.

bloom_filter_mod.hash2(int_list)[source]

Hash input: function #2.

bloom_filter_mod.simple_hash(int_list, prime1, prime2, prime3)[source]

Compute a hash value from a list of integers and 3 primes.

Delete a file. Don’t complain if it’s not there.