W
- The type of Windows
on which this Evictor
can operate.@PublicEvolving public class TimeEvictor<W extends Window> extends Object implements Evictor<Object,W>
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
Evictor.EvictorContext
Constructor and Description |
---|
TimeEvictor(long windowSize) |
TimeEvictor(long windowSize,
boolean doEvictAfter) |
Modifier and Type | Method and Description |
---|---|
void |
evictAfter(Iterable<TimestampedValue<Object>> elements,
int size,
W window,
Evictor.EvictorContext ctx)
Optionally evicts elements.
|
void |
evictBefore(Iterable<TimestampedValue<Object>> elements,
int size,
W window,
Evictor.EvictorContext ctx)
Optionally evicts elements.
|
long |
getWindowSize() |
static <W extends Window> |
of(Time windowSize)
Creates a
TimeEvictor that keeps the given number of elements. |
static <W extends Window> |
of(Time windowSize,
boolean doEvictAfter)
Creates a
TimeEvictor that keeps the given number of elements. |
String |
toString() |
public TimeEvictor(long windowSize)
public TimeEvictor(long windowSize, boolean doEvictAfter)
public void evictBefore(Iterable<TimestampedValue<Object>> elements, int size, W window, Evictor.EvictorContext ctx)
Evictor
public void evictAfter(Iterable<TimestampedValue<Object>> elements, int size, W window, Evictor.EvictorContext ctx)
Evictor
@VisibleForTesting public long getWindowSize()
public static <W extends Window> TimeEvictor<W> of(Time windowSize)
TimeEvictor
that keeps the given number of elements.
Eviction is done before the window function.windowSize
- The amount of time for which to keep elements.public static <W extends Window> TimeEvictor<W> of(Time windowSize, boolean doEvictAfter)
TimeEvictor
that keeps the given number of elements.
Eviction is done before/after the window function based on the value of doEvictAfter.windowSize
- The amount of time for which to keep elements.doEvictAfter
- Whether eviction is done after window function.Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.