Class BloomFilterDictionary

  • All Implemented Interfaces:

    public class BloomFilterDictionary
    extends Object
    implements Dictionary
    Dictionary that is backed by a Bloom Filter. WARNING bloom filters may return true for a word that is NOT in the dictionary. This implementation should only be used if false positives can be tolerated.
    Middleware Services
    • Constructor Detail

      • BloomFilterDictionary

        public BloomFilterDictionary​(<String> bf)
        Creates a new dictionary instance from the supplied BloomFilter. The fpp (false-positive probability) parameter of the given Bloom filter is a vitally important configuration concern. If it is too high, one risks user frustration due to rejection of valid passwords; if it is too low, one risks excessive storage costs. Finding the proper balance between acceptable user experience and storage costs is worth the time and effort required in testing. The Guava default value of 3% is likely unsuitable for many if not most deployments.
        bf - bloom filter used to determine if a word exists.
    • Method Detail

      • getBloomFilter

        public<String> getBloomFilter()
        Returns the bloom filter used for searching.
        bloom filter
      • size

        public long size()
        Returns an estimate for the number of words added to the dictionary. See BloomFilter.approximateElementCount().
        Specified by:
        size in interface Dictionary
        approximate number of words in the dictionary
      • search

        public boolean search​(String word)
        WARNING bloom filters may return true for a word that is NOT in the dictionary. Please make sure you understand how bloom filters work before using this implementation. @see Bloom Filter and BloomFilter.mightContain(Object).
        Specified by:
        search in interface Dictionary
        word - to search for
        true if the word might be in the bloom filter, false if the word is definitely not in the bloom filter