Package org.apache.hadoop.hdfs.util
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
Note: This class is NOT thread-safe.
Hold the references count to a single instance. If there are no references then the entry will be removed.
Type E should implement
ReferenceCountMap.ReferenceCounterNote: This class is NOT thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for the reference count holder -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear the contentsorg.apache.hadoop.thirdparty.com.google.common.collect.ImmutableList<E>Get entries in the reference Map.longgetReferenceCount(E key) Get the reference count for the keyintGet the number of unique elementsAdd the reference.voidDelete the reference.
-
Constructor Details
-
ReferenceCountMap
public ReferenceCountMap()
-
-
Method Details
-
put
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
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
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
-