system.indexes.bloom_filters module

Bloom filter implementation for approximate set-membership tests.

class system.indexes.bloom_filters.BloomFilter(data_objects: list[~typing.Any], number_of_available_bits: int, key_attribute_name: str, bit_sequence_type: ~typing.Type[~system.interfaces.bit_sequence.UncompressedBitSequence], hash_iterator_type: ~typing.Type[~system.indexes.bloom_filters.BloomFilter.HashIterator] = <class 'system.indexes.bloom_filters.BloomFilter.RNGHashIterator'>)[source]

Bases: object

Implements a bloom filters for efficient filtering.

class HashIterator(key: int, number_of_hash_functions: int, number_of_available_bits: int)[source]

Bases: ABC

Abstract iterator to iterate through all hash values for a given key.

class RNGHashIterator(key: int, number_of_hash_functions: int, number_of_available_bits: int)[source]

Bases: HashIterator

Iterator making use of RNGs to create pseudo hash values. NEVER USE THIS IN A PRODUCTION SYSTEM!!

contains_key(key: int) → bool[source]

Checks if the given key is present in the bloom filter. Can be a false positive! :param key: The key to be checked. :return: True if the key is present in the bloom filter (might be a false positive), False otherwise.