Package org.carrot2.util
Class RollingWindowAverage
java.lang.Object
org.carrot2.util.RollingWindowAverage
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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
add
(long timestamp, long value) Adds a new entry.final double
final long
Returns the number of updates kept in the rolling window's scope.final long
Returns the size of the rolling window.
-
Field Details
-
MILLIS
public static final int MILLISHelpful constant for one millisecond.- See Also:
-
SECOND
public static final int SECONDHelpful constant for one second.- See Also:
-
MINUTE
public static final int MINUTEHelpful constant for one minute.- See Also:
-
-
Constructor Details
-
RollingWindowAverage
public RollingWindowAverage(long windowSizeMillis, long bucketSizeMillis)
-
-
Method Details
-
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.
-