|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.s4.core.ProcessingElement
org.apache.s4.core.window.AbstractSlidingWindowPE<T,U,V>
T
- type of the slot implementation used for this windowU
- type of the values added to the window slotspublic abstract class AbstractSlidingWindowPE<T extends Slot<U>,U,V>
Abstract ProcessingElement that can store historical values using a sliding window. Each set of values is called a slot. Each slot represents a segment of time or a fixed number of events. Slots are consecutive in time or events. Users are expected to provide a factory for creating new slots, and a method to perform a global computation on the current window. Slots are automatically added. WHen using time-based slots, use this implementation only if you expect most slots to have values, it is not efficient for sparse event streams.
Field Summary |
---|
Fields inherited from class org.apache.s4.core.ProcessingElement |
---|
app, id |
Constructor Summary | |
---|---|
AbstractSlidingWindowPE(App app,
int numSlots,
long slotCapacity,
SlotFactory<T> slotFactory)
Constructor for the event-based slot. |
|
AbstractSlidingWindowPE(App app,
long slotDuration,
java.util.concurrent.TimeUnit timeUnit,
int numSlots,
SlotFactory<T> slotFactory)
Constructor for time-based slots. |
Method Summary | |
---|---|
protected void |
addSlot()
Add a slot to the sliding window. |
protected abstract V |
evaluateWindow(java.util.Collection<T> slots)
User provided function that evaluates the whole content of the window. |
protected T |
getOldestSlot()
|
protected T |
getOpenSlot()
|
protected java.util.Collection<T> |
getSlots()
|
protected void |
initPEPrototypeInternal()
|
protected void |
onCreate()
This method is called after a PE instance is created. |
protected void |
onRemove()
This method is called before a PE instance is removed. |
void |
onTrigger(Event event)
For count-based windows, we use a trigger that adds a new slot when the current one reaches its maximum capacity. |
protected void |
stop()
Stops the the sliding window. |
protected void |
updateOpenSlot(U data)
|
Methods inherited from class org.apache.s4.core.ProcessingElement |
---|
checkpoint, clearDirty, clone, close, deserializeState, emit, getApp, getCheckpointingConfig, getEventCount, getId, getInstanceForKey, getInstances, getName, getNumPEInstances, getPEInstances, getPrototype, getRemoteInstances, getRemoteInstancesForKey, getTimerInterval, handleInputEvent, isCheckpointable, isDirty, isSingleton, isThreadSafe, onTime, recover, removeAll, restoreState, serializeState, setApp, setCheckpointingConfig, setName, setPECache, setPECache, setSingleton, setTimerInterval, setTrigger, toString |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AbstractSlidingWindowPE(App app, int numSlots, long slotCapacity, SlotFactory<T> slotFactory)
addSlot()
must be called by the concrete
class.
app
- the applicationnumSlots
- the number of slots to be storedpublic AbstractSlidingWindowPE(App app, long slotDuration, java.util.concurrent.TimeUnit timeUnit, int numSlots, SlotFactory<T> slotFactory)
addSlot()
is called periodically.
app
- the applicationslotDuration
- the slot duration in timeUnittimeUnit
- the unit of timenumSlots
- the number of slots to be storedMethod Detail |
---|
protected void onRemove()
ProcessingElement
onRemove
in class ProcessingElement
public final void onTrigger(Event event)
protected void initPEPrototypeInternal()
initPEPrototypeInternal
in class ProcessingElement
protected abstract V evaluateWindow(java.util.Collection<T> slots)
protected final void addSlot()
protected void onCreate()
ProcessingElement
Fields initialized in the class constructor are shared by all PE instances.
onCreate
in class ProcessingElement
protected void updateOpenSlot(U data)
protected T getOldestSlot()
protected void stop()
protected java.util.Collection<T> getSlots()
protected T getOpenSlot()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |