Class RollingStatCalculator

java.lang.Object
org.apache.hadoop.hbase.util.RollingStatCalculator

@Private public class RollingStatCalculator extends Object
This class maintains mean and variation for any sequence of input provided to it. It is initialized with number of rolling periods which basically means the number of past inputs whose data will be considered to maintain mean and variation. It will use O(N) memory to maintain these statistics, where N is number of look up periods it was initialized with. If zero is passed during initialization then it will maintain mean and variance from the start. It will use O(1) memory only. But note that since it will maintain mean / variance from the start the statistics may behave like constants and may ignore short trends. All operations are O(1) except the initialization which is O(N).
  • Field Details

  • Constructor Details

    • RollingStatCalculator

      public RollingStatCalculator(int rollingPeriod)
      Creates a RollingStatCalculator with given number of rolling periods.
  • Method Details

    • insertDataValue

      public void insertDataValue(long data)
      Inserts given data value to array of data values to be considered for statistics calculation
    • removeData

      private void removeData(long data)
      Update the statistics after removing the given data value
    • getMean

      public double getMean()
      Returns mean of the data values that are in the current list of data values
    • getDeviation

      public double getDeviation()
      Returns deviation of the data values that are in the current list of data values
    • fillWithZeros

      private long[] fillWithZeros(int size)
      Returns an array of given size initialized with zeros