Class BloomFilter

java.lang.Object
org.infinispan.server.resp.commands.bloom.BloomFilter

@ProtoTypeId(6136) public final class BloomFilter extends Object
A Bloom filter implementation compatible with Redis BF commands.

Supports:

  • Configurable error rate and capacity
  • Scaling with multiple sub-filters
  • Non-scaling mode
Since:
16.2
  • Field Details

    • DEFAULT_ERROR_RATE

      public static final double DEFAULT_ERROR_RATE
      Default values used when creating a filter with BF.ADD without BF.RESERVE.
      See Also:
    • DEFAULT_CAPACITY

      public static final long DEFAULT_CAPACITY
      See Also:
    • DEFAULT_EXPANSION

      public static final int DEFAULT_EXPANSION
      See Also:
  • Constructor Details

    • BloomFilter

      public BloomFilter(double errorRate, long capacity, int expansion, boolean nonScaling)
  • Method Details

    • getErrorRate

      @ProtoField(number=1, defaultValue="0.01") public double getErrorRate()
    • getCapacity

      @ProtoField(number=2, defaultValue="100") public long getCapacity()
    • getExpansion

      @ProtoField(number=3, defaultValue="2") public int getExpansion()
    • isNonScaling

      @ProtoField(number=4, defaultValue="false") public boolean isNonScaling()
    • getSubFilters

      @ProtoField(number=5) public List<BloomFilter.SubFilter> getSubFilters()
    • getItemCount

      @ProtoField(number=6, defaultValue="0") public long getItemCount()
    • add

      public boolean add(byte[] item)
      Adds an item to the Bloom filter.
      Parameters:
      item - the item to add
      Returns:
      true if the item was newly added, false if it probably already existed
      Throws:
      IllegalStateException - if the filter is full and non-scaling
    • mightContain

      public boolean mightContain(byte[] item)
      Checks if an item might be contained in the Bloom filter.
      Parameters:
      item - the item to check
      Returns:
      true if the item might be in the filter (with false positive probability), false if the item is definitely not in the filter
    • getTotalCapacity

      public long getTotalCapacity()
      Returns the total capacity across all sub-filters.
    • getSize

      public long getSize()
      Returns the total size in bytes.
    • getFilterCount

      public int getFilterCount()
      Returns the number of sub-filters.