Class ReferenceCountMap<E extends ReferenceCountMap.ReferenceCounter>

java.lang.Object
org.apache.hadoop.hdfs.util.ReferenceCountMap<E>

@Private @Evolving public class ReferenceCountMap<E extends ReferenceCountMap.ReferenceCounter> extends Object
Class for de-duplication of instances.
Hold the references count to a single instance. If there are no references then the entry will be removed.
Type E should implement ReferenceCountMap.ReferenceCounter
Note: This class is NOT thread-safe.
  • Constructor Details

    • ReferenceCountMap

      public ReferenceCountMap()
  • Method Details

    • put

      public E put(E key)
      Add the reference. If the instance already present, just increase the reference count.
      Parameters:
      key - Key to put in reference map
      Returns:
      Referenced instance
    • remove

      public void remove(E key)
      Delete the reference. Decrease the reference count for the instance, if any. On all references removal delete the instance from the map.
      Parameters:
      key - Key to remove the reference.
    • getEntries

      @VisibleForTesting public org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableList<E> getEntries()
      Get entries in the reference Map.
      Returns:
    • getReferenceCount

      public long getReferenceCount(E key)
      Get the reference count for the key
    • getUniqueElementsSize

      public int getUniqueElementsSize()
      Get the number of unique elements
    • clear

      @VisibleForTesting public void clear()
      Clear the contents