Class CountMin4
- java.lang.Object
-
- com.github.benmanes.caffeine.cache.simulator.admission.countmin4.CountMin4
-
- All Implemented Interfaces:
Frequency
- Direct Known Subclasses:
ClimberResetCountMin4,IncrementalResetCountMin4,PeriodicResetCountMin4
public abstract class CountMin4 extends Object implements Frequency
A probabilistic multiset for estimating the popularity of an element within a time window. The maximum frequency of an element is limited to 15 (4-bits) and extensions provide the aging process.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanconservativeprotected intstepprotected long[]tableprotected inttableMask
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidensureCapacity(long maximumSize)Increases the capacity of this FrequencySketch instance, if necessary, to ensure that it can accurately estimate the popularity of elements given the maximum size of the cache.intfrequency(long e)Returns the estimated number of occurrences of an element, up to the maximum (15).voidincrement(long e)Increments the popularity of the element if it does not exceed the maximum (15).protected abstract voidtryReset(boolean added)Performs the aging process after an addition to allow old entries to fade away.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.benmanes.caffeine.cache.simulator.admission.Frequency
reportMiss
-
-
-
-
Constructor Detail
-
CountMin4
protected CountMin4(Config config)
Creates a frequency sketch that can accurately estimate the popularity of elements given the maximum size of the cache.
-
-
Method Detail
-
ensureCapacity
protected void ensureCapacity(long maximumSize)
Increases the capacity of this FrequencySketch instance, if necessary, to ensure that it can accurately estimate the popularity of elements given the maximum size of the cache. This operation forgets all previous counts when resizing.- Parameters:
maximumSize- the maximum size of the cache
-
frequency
public int frequency(long e)
Returns the estimated number of occurrences of an element, up to the maximum (15).
-
increment
public void increment(long e)
Increments the popularity of the element if it does not exceed the maximum (15). The popularity of all elements will be periodically down sampled when the observed events exceed a threshold. This process provides a frequency aging to allow expired long term entries to fade away.
-
tryReset
protected abstract void tryReset(boolean added)
Performs the aging process after an addition to allow old entries to fade away.
-
-