Class CountMin4

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean conservative  
      protected int step  
      protected long[] table  
      protected int tableMask  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected CountMin4​(Config config)
      Creates a frequency sketch that can accurately estimate the popularity of elements given the maximum size of the cache.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      int frequency​(long e)
      Returns the estimated number of occurrences of an element, up to the maximum (15).
      void increment​(long e)
      Increments the popularity of the element if it does not exceed the maximum (15).
      protected abstract void tryReset​(boolean added)
      Performs the aging process after an addition to allow old entries to fade away.
      • Methods inherited from interface com.github.benmanes.caffeine.cache.simulator.admission.Frequency

        reportMiss
    • Field Detail

      • conservative

        protected final boolean conservative
      • tableMask

        protected int tableMask
      • table

        protected long[] table
      • step

        protected int step
    • 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).
        Specified by:
        frequency in interface Frequency
        Parameters:
        e - the element to count occurrences of
        Returns:
        the estimated number of occurrences of the element; possibly zero but never negative
      • 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.
        Specified by:
        increment in interface Frequency
        Parameters:
        e - the element to add
      • tryReset

        protected abstract void tryReset​(boolean added)
        Performs the aging process after an addition to allow old entries to fade away.