Class CountEvictor<W extends Window>

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

@PublicEvolving public class CountEvictor<W extends Window> extends Object implements Evictor<Object,W>
An Evictor that keeps up to a certain amount of elements.
See Also:
  • Method Details

    • evictBefore

      public void evictBefore(Iterable<TimestampedValue<Object>> elements, int size, W window, Evictor.EvictorContext ctx)
      Description copied from interface: Evictor
      Optionally evicts elements. Called before windowing function.
      Specified by:
      evictBefore in interface Evictor<Object,W extends Window>
      Parameters:
      elements - The elements currently in the pane.
      size - The current number of elements in the pane.
      window - The Window
      ctx - The context for the Evictor
    • evictAfter

      public void evictAfter(Iterable<TimestampedValue<Object>> elements, int size, W window, Evictor.EvictorContext ctx)
      Description copied from interface: Evictor
      Optionally evicts elements. Called after windowing function.
      Specified by:
      evictAfter in interface Evictor<Object,W extends Window>
      Parameters:
      elements - The elements currently in the pane.
      size - The current number of elements in the pane.
      window - The Window
      ctx - The context for the Evictor
    • of

      public static <W extends Window> CountEvictor<W> of(long maxCount)
      Creates a CountEvictor that keeps the given number of elements. Eviction is done before the window function.
      Parameters:
      maxCount - The number of elements to keep in the pane.
    • of

      public static <W extends Window> CountEvictor<W> of(long maxCount, boolean doEvictAfter)
      Creates a CountEvictor that keeps the given number of elements in the pane Eviction is done before/after the window function based on the value of doEvictAfter.
      Parameters:
      maxCount - The number of elements to keep in the pane.
      doEvictAfter - Whether to do eviction after the window function.