Class CuckooFilter
java.lang.Object
org.infinispan.server.resp.commands.cuckoo.CuckooFilter
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA sub-filter in a scalable Cuckoo filter. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final longstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionCuckooFilter(long capacity, int bucketSize, int maxIterations, int expansion) -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(byte[] item) Adds an item to the Cuckoo filter.booleanaddNx(byte[] item) Adds an item only if it doesn't already exist.longcount(byte[] item) Counts occurrences of an item in the filter.booleandelete(byte[] item) Deletes one occurrence of an item from the filter.booleanexists(byte[] item) Checks if an item might exist in the filter.intlongintintReturns the number of sub-filters.longlongintlonggetSize()Returns the total size in bytes.longReturns the total number of buckets across all sub-filters.
-
Field Details
-
DEFAULT_CAPACITY
public static final long DEFAULT_CAPACITY- See Also:
-
DEFAULT_BUCKET_SIZE
public static final int DEFAULT_BUCKET_SIZE- See Also:
-
DEFAULT_MAX_ITERATIONS
public static final int DEFAULT_MAX_ITERATIONS- See Also:
-
DEFAULT_EXPANSION
public static final int DEFAULT_EXPANSION- See Also:
-
-
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
-
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.
-