org.apache.lucene.util

Class FrequencyTrackingRingBuffer

  • All Implemented Interfaces:
    Accountable


    public final class FrequencyTrackingRingBuffer
    extends Object
    implements Accountable
    A ring buffer that tracks the frequency of the integers that it contains. This is typically useful to track the hash codes of popular recently-used items. This data-structure requires 22 bytes per entry on average (between 16 and 28).
    • Constructor Detail

      • FrequencyTrackingRingBuffer

        public FrequencyTrackingRingBuffer(int maxSize,
                                           int sentinel)
        Create a new ring buffer that will contain at most maxSize items. This buffer will initially contain maxSize times the sentinel value.
    • Method Detail

      • add

        public void add(int i)
        Add a new item to this ring buffer, potentially removing the oldest entry from this buffer if it is already full.
      • frequency

        public int frequency(int key)
        Returns the frequency of the provided key in the ring buffer.