类 WindowManager<T>

java.lang.Object
org.apache.pulsar.functions.windowing.WindowManager<T>
类型参数:
T - the type of event in the window.
所有已实现的接口:
TriggerHandler

public class WindowManager<T> extends Object implements TriggerHandler
Tracks a window of events and fires WindowLifecycleListener callbacks on expiry of events or activation of the window due to TriggerPolicy.
  • 字段详细资料

    • EXPIRE_EVENTS_THRESHOLD

      protected static final int EXPIRE_EVENTS_THRESHOLD
      Expire old events every EXPIRE_EVENTS_THRESHOLD to keep the window size in check.

      Note that if the eviction policy is based on watermarks, events will not be evicted until a new watermark would cause them to be considered expired anyway, regardless of this limit

      另请参阅:
    • queue

      protected final Collection<Event<T>> queue
    • evictionPolicy

      protected EvictionPolicy<T,?> evictionPolicy
    • triggerPolicy

      protected TriggerPolicy<T,?> triggerPolicy
    • windowLifecycleListener

      protected final WindowLifecycleListener<Event<T>> windowLifecycleListener
  • 构造器详细资料

  • 方法详细资料

    • setEvictionPolicy

      public void setEvictionPolicy(EvictionPolicy<T,?> evictionPolicy)
    • setTriggerPolicy

      public void setTriggerPolicy(TriggerPolicy<T,?> triggerPolicy)
    • add

      public void add(T event, long ts, org.apache.pulsar.functions.api.Record<?> record)
      Add an event into the window, with the given ts as the tracking ts.
      参数:
      event - the event to track
      ts - the timestamp
    • add

      public void add(Event<T> windowEvent)
      Tracks a window event
      参数:
      windowEvent - the window event to track
    • onTrigger

      public boolean onTrigger()
      The callback invoked by the trigger policy.
      指定者:
      onTrigger 在接口中 TriggerHandler
      返回:
      true if the window was evaluated with at least one event in the window, false otherwise
    • shutdown

      public void shutdown()
    • compactWindow

      protected void compactWindow()
      expires events that fall out of the window every EXPIRE_EVENTS_THRESHOLD so that the window does not grow too big.
    • getEarliestEventTs

      public long getEarliestEventTs(long startTs, long endTs)
      Scans the event queue and returns the next earliest event ts between the startTs and endTs.
      参数:
      startTs - the start ts (exclusive)
      endTs - the end ts (inclusive)
      返回:
      the earliest event ts between startTs and endTs
    • getEventCount

      public int getEventCount(long referenceTime)
      Scans the event queue and returns number of events having timestamp less than or equal to the reference time.
      参数:
      referenceTime - the reference timestamp in millis
      返回:
      the count of events with timestamp less than or equal to referenceTime
    • getSlidingCountTimestamps

      public List<Long> getSlidingCountTimestamps(long startTs, long endTs, int slidingCount)
      Scans the event queue and returns the list of event ts falling between startTs (exclusive) and endTs (inclusive) at each sliding interval counts.
      参数:
      startTs - the start timestamp (exclusive)
      endTs - the end timestamp (inclusive)
      slidingCount - the sliding interval count
      返回:
      the list of event ts
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object