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(Duration windowSize)
Creates a
TimeEvictor that keeps the given number of elements. |
static <W extends Window> |
of(Duration windowSize,
boolean doEvictAfter)
Creates a
TimeEvictor that keeps the given number of elements. |
static <W extends Window> |
of(Time windowSize)
Deprecated.
Use
of(Duration) |
static <W extends Window> |
of(Time windowSize,
boolean doEvictAfter)
Deprecated.
|
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()
@Deprecated public static <W extends Window> TimeEvictor<W> of(Time windowSize)
of(Duration)
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(Duration 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.@Deprecated public static <W extends Window> TimeEvictor<W> of(Time windowSize, boolean doEvictAfter)
of(Duration, boolean)
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.public static <W extends Window> TimeEvictor<W> of(Duration 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–2024 The Apache Software Foundation. All rights reserved.