Package org.apache.hadoop.hbase.util
Class RollingStatCalculator
java.lang.Object
org.apache.hadoop.hbase.util.RollingStatCalculator
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 Summary
Modifier and TypeFieldDescriptionprivate int
private double
private double
private long[]
private long
private int
-
Constructor Summary
ConstructorDescriptionRollingStatCalculator
(int rollingPeriod) Creates a RollingStatCalculator with given number of rolling periods. -
Method Summary
Modifier and TypeMethodDescriptionprivate long[]
fillWithZeros
(int size) Returns an array of given size initialized with zerosdouble
Returns deviation of the data values that are in the current list of data valuesdouble
getMean()
Returns mean of the data values that are in the current list of data valuesvoid
insertDataValue
(long data) Inserts given data value to array of data values to be considered for statistics calculationprivate void
removeData
(long data) Update the statistics after removing the given data value
-
Field Details
-
currentSum
-
currentSqrSum
-
numberOfDataValues
-
rollingPeriod
-
currentIndexPosition
-
dataValues
-
-
Constructor Details
-
RollingStatCalculator
Creates a RollingStatCalculator with given number of rolling periods.
-
-
Method Details
-
insertDataValue
Inserts given data value to array of data values to be considered for statistics calculation -
removeData
Update the statistics after removing the given data value -
getMean
Returns mean of the data values that are in the current list of data values -
getDeviation
Returns deviation of the data values that are in the current list of data values -
fillWithZeros
Returns an array of given size initialized with zeros
-