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

  • 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:
    Serialized Form
    • 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)  
    • Constructor Detail

      • TimeEvictor

        public TimeEvictor​(long windowSize)
      • TimeEvictor

        public TimeEvictor​(long windowSize,
                           boolean doEvictAfter)
    • Method Detail

      • 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>
      • 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.