Class TimeEvictor<W extends org.apache.flink.streaming.api.windowing.windows.Window>

java.lang.Object
org.apache.flink.streaming.api.windowing.evictors.TimeEvictor<W>
Type Parameters:
W - The type of Windows on which this Evictor can operate.
All Implemented Interfaces:
Serializable, org.apache.flink.streaming.api.windowing.evictors.Evictor<Object,W>

@PublicEvolving public class TimeEvictor<W extends org.apache.flink.streaming.api.windowing.windows.Window> extends Object implements org.apache.flink.streaming.api.windowing.evictors.Evictor<Object,W>
An Evictor that keeps elements for a certain amount of time. Elements older than current_time - keep_time are evicted. The current_time is time associated with TimestampedValue
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.flink.streaming.api.windowing.evictors.Evictor

    org.apache.flink.streaming.api.windowing.evictors.Evictor.EvictorContext
  • Constructor Summary

    Constructors
    Constructor
    Description
    TimeEvictor(long windowSize)
     
    TimeEvictor(long windowSize, boolean doEvictAfter)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    evictAfter(Iterable<org.apache.flink.streaming.runtime.operators.windowing.TimestampedValue<Object>> elements, int size, W window, org.apache.flink.streaming.api.windowing.evictors.Evictor.EvictorContext ctx)
     
    void
    evictBefore(Iterable<org.apache.flink.streaming.runtime.operators.windowing.TimestampedValue<Object>> elements, int size, W window, org.apache.flink.streaming.api.windowing.evictors.Evictor.EvictorContext ctx)
     
    long
     
    static <W extends org.apache.flink.streaming.api.windowing.windows.Window>
    TimeEvictor<W>
    of(Duration windowSize)
    Creates a TimeEvictor that keeps the given number of elements.
    static <W extends org.apache.flink.streaming.api.windowing.windows.Window>
    TimeEvictor<W>
    of(Duration windowSize, boolean doEvictAfter)
    Creates a TimeEvictor that keeps the given number of elements.
     

    Methods inherited from class java.lang.Object

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

    • TimeEvictor

      public TimeEvictor(long windowSize)
    • TimeEvictor

      public TimeEvictor(long windowSize, boolean doEvictAfter)
  • Method Details

    • evictBefore

      public void evictBefore(Iterable<org.apache.flink.streaming.runtime.operators.windowing.TimestampedValue<Object>> elements, int size, W window, org.apache.flink.streaming.api.windowing.evictors.Evictor.EvictorContext ctx)
      Specified by:
      evictBefore in interface org.apache.flink.streaming.api.windowing.evictors.Evictor<Object,W extends org.apache.flink.streaming.api.windowing.windows.Window>
    • evictAfter

      public void evictAfter(Iterable<org.apache.flink.streaming.runtime.operators.windowing.TimestampedValue<Object>> elements, int size, W window, org.apache.flink.streaming.api.windowing.evictors.Evictor.EvictorContext ctx)
      Specified by:
      evictAfter in interface org.apache.flink.streaming.api.windowing.evictors.Evictor<Object,W extends org.apache.flink.streaming.api.windowing.windows.Window>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getWindowSize

      @VisibleForTesting public long getWindowSize()
    • of

      public static <W extends org.apache.flink.streaming.api.windowing.windows.Window> TimeEvictor<W> of(Duration windowSize)
      Creates a TimeEvictor that keeps the given number of elements. Eviction is done before the window function.
      Parameters:
      windowSize - The amount of time for which to keep elements.
    • of

      public static <W extends org.apache.flink.streaming.api.windowing.windows.Window> TimeEvictor<W> of(Duration windowSize, boolean doEvictAfter)
      Creates a TimeEvictor that keeps the given number of elements. Eviction is done before/after the window function based on the value of doEvictAfter.
      Parameters:
      windowSize - The amount of time for which to keep elements.
      doEvictAfter - Whether eviction is done after window function.