Class RollingWindowAverage


  • public class RollingWindowAverage
    extends Object
    Calculates an average of values showing up in a given time window. To keep processing efficient, bucketing is performed.

    This class is not thread-safe.

    • Constructor Detail

      • RollingWindowAverage

        public RollingWindowAverage​(long windowSizeMillis,
                                    long bucketSizeMillis)
    • Method Detail

      • add

        public final void add​(long timestamp,
                              long value)
        Adds a new entry.
      • getCurrentAverage

        public final double getCurrentAverage()
      • getUpdatesInWindow

        public final long getUpdatesInWindow()
        Returns the number of updates kept in the rolling window's scope.
      • getWindowSizeMillis

        public final long getWindowSizeMillis()
        Returns the size of the rolling window.