Class BloomFilterUtils

java.lang.Object
org.apache.sling.resourceresolver.impl.mapping.BloomFilterUtils

public class BloomFilterUtils extends Object
Bloom filter utilities.
  • Constructor Details

    • BloomFilterUtils

      public BloomFilterUtils()
  • Method Details

    • createFilter

      public static byte[] createFilter(int elementCount, int maxBytes)
      Create a bloom filter array for the given number of elements.
      Parameters:
      elementCount - the number of entries
      maxBytes - the maximum number of bytes
      Returns:
      the empty bloom filter
    • add

      public static void add(byte[] bloom, Object key)
      Add the key.
      Parameters:
      bloom - the bloom filter
      key - the key
    • remove

      public static void remove(byte[] bloom, Object key)
      Remove the key.
      Parameters:
      bloom - the bloom filter
      key - the key
    • probablyContains

      public static boolean probablyContains(byte[] bloom, Object key)
      Check whether the given key is probably in the set. This method never returns false if the key is in the set, but possibly returns true even if it isn't.
      Parameters:
      bloom - the bloom filter
      key - the key
      Returns:
      true if the given key is probably in the set