Class FrequencyTrackingRingBuffer.IntBag

java.lang.Object
org.apache.lucene.util.FrequencyTrackingRingBuffer.IntBag
All Implemented Interfaces:
Accountable
Enclosing class:
FrequencyTrackingRingBuffer

private static class FrequencyTrackingRingBuffer.IntBag extends Object implements Accountable
A bag of integers. Since in the context of the ring buffer the maximum size is known up-front there is no need to worry about resizing the underlying storage.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final long
     
    private final int[]
     
    private final int[]
     
    private final int
     

    Fields inherited from interface org.apache.lucene.util.Accountable

    NULL_ACCOUNTABLE
  • Constructor Summary

    Constructors
    Constructor
    Description
    IntBag(int maxSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) int
    add(int key)
    Increment the frequency of the given key by 1 and return its new frequency.
    (package private) Map<Integer,Integer>
     
    private static boolean
    between(int chainStart, int chainEnd, int slot)
    Given a chain of occupied slots between chainStart and chainEnd, return whether slot is between the start and end of the chain.
    (package private) int
    frequency(int key)
    Return the frequency of the give key in the bag.
    long
    Return the memory usage of this object in bytes.
    private void
    relocateAdjacentKeys(int freeSlot)
     
    (package private) boolean
    remove(int key)
    Decrement the frequency of the given key by one, or do nothing if the key is not present in the bag.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.lucene.util.Accountable

    getChildResources
  • Field Details

    • BASE_RAM_BYTES_USED

      private static final long BASE_RAM_BYTES_USED
    • keys

      private final int[] keys
    • freqs

      private final int[] freqs
    • mask

      private final int mask
  • Constructor Details

    • IntBag

      IntBag(int maxSize)
  • Method Details

    • ramBytesUsed

      public long ramBytesUsed()
      Description copied from interface: Accountable
      Return the memory usage of this object in bytes. Negative values are illegal.
      Specified by:
      ramBytesUsed in interface Accountable
    • frequency

      int frequency(int key)
      Return the frequency of the give key in the bag.
    • add

      int add(int key)
      Increment the frequency of the given key by 1 and return its new frequency.
    • remove

      boolean remove(int key)
      Decrement the frequency of the given key by one, or do nothing if the key is not present in the bag. Returns true iff the key was contained in the bag.
    • relocateAdjacentKeys

      private void relocateAdjacentKeys(int freeSlot)
    • between

      private static boolean between(int chainStart, int chainEnd, int slot)
      Given a chain of occupied slots between chainStart and chainEnd, return whether slot is between the start and end of the chain.
    • asMap

      Map<Integer,Integer> asMap()