org.apache.storm.starter.tools

## Class SlotBasedCounter<T>

- java.lang.Object
- - org.apache.storm.starter.tools.SlotBasedCounter<T>

- All Implemented Interfaces:
    Serializable

      public final class SlotBasedCounter<T>
      extends Object
      implements 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:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SlotBasedCounter(int numSlots)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getCount(T obj, int slot)`
    `Map<T,Long>` | `getCounts()`
    `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` | `wipeZeros()` Remove any object from the counter whose total count is zero (to free up memory).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SlotBasedCounter

          public SlotBasedCounter(int numSlots)

  - ### Method Detail

    - #### incrementCount

          public void incrementCount(T obj,
                                     int slot)

    - #### getCount

          public long getCount(T obj,
                               int slot)

    - #### getCounts

          public Map<T,Long> 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).

Copyright © 2019 The Apache Software Foundation. All rights reserved.