Class EnumCounters<E extends Enum<E>>

java.lang.Object
org.apache.hadoop.hdfs.util.EnumCounters<E>
Type Parameters:
E - the enum type
Direct Known Subclasses:
ConstEnumCounters, NumberReplicas, Quota.Counts

public class EnumCounters<E extends Enum<E>> extends Object
Counters for an enum type. For example, suppose there is an enum type
 enum Fruit { APPLE, ORANGE, GRAPE }
 
An EnumCounters object can be created for counting the numbers of APPLE, ORANGE and GRAPE.
  • Constructor Details

    • EnumCounters

      public EnumCounters(Class<E> enumClass)
      Construct counters for the given enum constants.
      Parameters:
      enumClass - the enum class of the counters.
    • EnumCounters

      public EnumCounters(Class<E> enumClass, long defaultVal)
  • Method Details

    • get

      public final long get(E e)
      Returns:
      the value of counter e.
    • asArray

      public long[] asArray()
      Returns:
      the values of counter as a shadow copy of array
    • negation

      public void negation()
      Negate all counters.
    • set

      public void set(E e, long value)
      Set counter e to the given value.
    • set

      public void set(EnumCounters<E> that)
      Set this counters to that counters.
    • reset

      public void reset()
      Reset all counters to zero.
    • add

      public void add(E e, long value)
      Add the given value to counter e.
    • add

      public void add(EnumCounters<E> that)
      Add that counters to this counters.
    • subtract

      public void subtract(E e, long value)
      Subtract the given value from counter e.
    • subtract

      public void subtract(EnumCounters<E> that)
      Subtract this counters from that counters.
    • sum

      public long sum()
      Returns:
      the sum of all counters.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • deepCopyEnumCounter

      public EnumCounters<E> deepCopyEnumCounter()
      Return a deep copy of EnumCounter.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • reset

      public void reset(long val)
    • allLessOrEqual

      public boolean allLessOrEqual(long val)
    • anyGreaterOrEqual

      public boolean anyGreaterOrEqual(long val)