Package org.apache.storm.starter.tools
Class SlotBasedCounter<T>
java.lang.Object
org.apache.storm.starter.tools.SlotBasedCounter<T>
- Type Parameters:
T
- The type of those objects we want to count.
- All Implemented Interfaces:
Serializable
This class provides per-slot counts of the occurrences of objects.
It can be used, for instance, as a building block for implementing sliding window counting of objects.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
void
incrementCount
(T obj, int slot) void
wipeSlot
(int slot) Reset the slot count of any tracked objects to zero for the given slot.void
Remove any object from the counter whose total count is zero (to free up memory).
-
Constructor Details
-
SlotBasedCounter
public SlotBasedCounter(int numSlots)
-
-
Method Details
-
incrementCount
-
getCount
-
getCounts
-
wipeSlot
public void wipeSlot(int slot) Reset the slot count of any tracked objects to zero for the given slot. -
wipeZeros
public void wipeZeros()Remove any object from the counter whose total count is zero (to free up memory).
-