Class CuckooFilter

java.lang.Object
org.infinispan.server.resp.commands.cuckoo.CuckooFilter

@ProtoTypeId(6144) public final class CuckooFilter extends Object
A Cuckoo filter implementation compatible with Redis CF commands.

Supports:

  • Configurable capacity, bucket size, and max iterations
  • Item deletion (unlike Bloom filters)
  • Counting occurrences
  • Scaling with multiple sub-filters
Since:
16.2
  • Field Details

  • Constructor Details

    • CuckooFilter

      public CuckooFilter(long capacity, int bucketSize, int maxIterations, int expansion)
  • Method Details

    • getCapacity

      @ProtoField(number=1, defaultValue="1024") public long getCapacity()
    • getBucketSize

      @ProtoField(number=2, defaultValue="2") public int getBucketSize()
    • getMaxIterations

      @ProtoField(number=3, defaultValue="20") public int getMaxIterations()
    • getExpansion

      @ProtoField(number=4, defaultValue="1") public int getExpansion()
    • getSubFilters

      @ProtoField(number=5) public List<CuckooFilter.SubFilter> getSubFilters()
    • getItemsInserted

      @ProtoField(number=6, defaultValue="0") public long getItemsInserted()
    • getItemsDeleted

      @ProtoField(number=7, defaultValue="0") public long getItemsDeleted()
    • add

      public boolean add(byte[] item)
      Adds an item to the Cuckoo filter. Allows duplicates.
      Parameters:
      item - the item to add
      Returns:
      true if item was added, false if filter is full
    • addNx

      public boolean addNx(byte[] item)
      Adds an item only if it doesn't already exist.
      Parameters:
      item - the item to add
      Returns:
      true if item was newly added, false if it already exists or filter is full
    • exists

      public boolean exists(byte[] item)
      Checks if an item might exist in the filter.
      Parameters:
      item - the item to check
      Returns:
      true if the item might exist, false if definitely not
    • count

      public long count(byte[] item)
      Counts occurrences of an item in the filter.
      Parameters:
      item - the item to count
      Returns:
      the count of occurrences
    • delete

      public boolean delete(byte[] item)
      Deletes one occurrence of an item from the filter.
      Parameters:
      item - the item to delete
      Returns:
      true if item was deleted, false if not found
    • getTotalBuckets

      public long getTotalBuckets()
      Returns the total number of buckets across all sub-filters.
    • getSize

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

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