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 an aging process periodically
halves the popularity of all elements.
Initializes and 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.
maximumSize - the maximum size of the cache
public int frequency(int hash)
Returns the estimated number of occurrences of an element, up to the maximum (15).
hash - the hash code of element to count occurrences of
the estimated number of occurrences of the element; possibly zero but never negative
public void increment(int hash)
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 exceeds a threshold.
This process provides a frequency aging to allow expired long term entries to fade away.