java.lang.Object
org.apache.flink.datastream.impl.extension.window.utils.WindowUtils

public final class WindowUtils extends Object
Utilities for Window extension.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<?,?>
    createWindowAssigner(org.apache.flink.datastream.api.extension.window.strategy.WindowStrategy windowStrategy)
    Create a WindowAssigner according to WindowStrategy.
    static <W extends org.apache.flink.streaming.api.windowing.windows.Window>
    void
    deleteCleanupTimer(W window, org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<?,?> windowAssigner, WindowTriggerContext<?,?,W> triggerContext, long allowedLateness)
    Deletes the cleanup timer set for the contents of the provided window.
    static long
    getAllowedLateness(org.apache.flink.datastream.api.extension.window.strategy.WindowStrategy windowStrategy)
    Get the allowed lateness for the window.
    static <W extends org.apache.flink.streaming.api.windowing.windows.Window>
    boolean
    isCleanupTime(W window, long time, org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<?,?> windowAssigner, long allowedLateness)
    Returns true if the given time is the cleanup time for the given window.
    static boolean
    isElementLate(org.apache.flink.streaming.runtime.streamrecord.StreamRecord<?> element, org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<?,?> windowAssigner, long allowedLateness, org.apache.flink.streaming.api.operators.InternalTimerService<?> internalTimerService)
    Decide if a record is currently late, based on current event time and allowed lateness.
    static <W extends org.apache.flink.streaming.api.windowing.windows.Window>
    boolean
    isWindowLate(W window, org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<?,W> windowAssigner, org.apache.flink.streaming.api.operators.InternalTimerService<W> internalTimerService, long allowedLateness)
    Returns true if the event time is after the end timestamp plus the allowed lateness of the given window.
    static <W extends org.apache.flink.streaming.api.windowing.windows.Window>
    void
    registerCleanupTimer(W window, org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<?,?> windowAssigner, WindowTriggerContext<?,?,W> triggerContext, long allowedLateness)
    Registers a timer to cleanup the content of the window.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WindowUtils

      public WindowUtils()
  • Method Details

    • getAllowedLateness

      public static long getAllowedLateness(org.apache.flink.datastream.api.extension.window.strategy.WindowStrategy windowStrategy)
      Get the allowed lateness for the window. Note that, in the current design, only TumblingTimeWindow and SlidingTimeWindow can have allowed lateness configured; for other types of windows, the returned allowed lateness will be 0.
    • createWindowAssigner

      public static org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<?,?> createWindowAssigner(org.apache.flink.datastream.api.extension.window.strategy.WindowStrategy windowStrategy)
      Create a WindowAssigner according to WindowStrategy.
    • isWindowLate

      public static <W extends org.apache.flink.streaming.api.windowing.windows.Window> boolean isWindowLate(W window, org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<?,W> windowAssigner, org.apache.flink.streaming.api.operators.InternalTimerService<W> internalTimerService, long allowedLateness)
      Returns true if the event time is after the end timestamp plus the allowed lateness of the given window.
    • isElementLate

      public static boolean isElementLate(org.apache.flink.streaming.runtime.streamrecord.StreamRecord<?> element, org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<?,?> windowAssigner, long allowedLateness, org.apache.flink.streaming.api.operators.InternalTimerService<?> internalTimerService)
      Decide if a record is currently late, based on current event time and allowed lateness.
      Parameters:
      element - The element to check
      windowAssigner - The window assigner
      allowedLateness - The allowed lateness of the window
      internalTimerService - The timer service to get current event time
      Returns:
      The element for which should be considered late
    • deleteCleanupTimer

      public static <W extends org.apache.flink.streaming.api.windowing.windows.Window> void deleteCleanupTimer(W window, org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<?,?> windowAssigner, WindowTriggerContext<?,?,W> triggerContext, long allowedLateness)
      Deletes the cleanup timer set for the contents of the provided window.
      Parameters:
      window - the window whose state to discard
      windowAssigner - The window assigner
      triggerContext - The trigger context
      allowedLateness - The allowed lateness of the window
    • registerCleanupTimer

      public static <W extends org.apache.flink.streaming.api.windowing.windows.Window> void registerCleanupTimer(W window, org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<?,?> windowAssigner, WindowTriggerContext<?,?,W> triggerContext, long allowedLateness)
      Registers a timer to cleanup the content of the window.
      Parameters:
      window - the window whose state to discard
      windowAssigner - The window assigner
      triggerContext - The trigger context
      allowedLateness - The allowed lateness of the window
    • isCleanupTime

      public static <W extends org.apache.flink.streaming.api.windowing.windows.Window> boolean isCleanupTime(W window, long time, org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<?,?> windowAssigner, long allowedLateness)
      Returns true if the given time is the cleanup time for the given window.