M
- the type of the input messageK
- the type of the key in the messageWV
- the type of the value in the window@InterfaceStability.Unstable public interface Window<M,K,WV>
MessageStream
into finite windows for processing.
A window is uniquely identified by its WindowKey
. A window can have one or more associated
Trigger
s that determine when results from the Window
are emitted.
Each emitted result contains one or more messages in the window and is called a WindowPane
.
A pane can include all messages collected for the window so far or only the new messages
since the last emitted pane. (as determined by the AccumulationMode
)
A window can have early triggers that allow emitting WindowPane
s speculatively before all data for the
window has arrived, or late triggers that allow handling late arrivals of data.
A Window
is said to be as "keyed" when the incoming MessageStream
is first grouped based on the provided key, and windowing is applied on the grouped stream.
window wk1 (with its triggers) +--------------------------------+ ------------+--------+-----------+ | | | | | pane 1 |pane2 | pane3 | +-----------+--------+-----------+ ----------------------------------- incoming message stream ------+ ----------------------------------- window wk2 +---------------------+---------+ | pane 1| pane 2 | pane 3 | | | | | +---------+-----------+---------+ window wk3 +----------+-----------+---------+ | | | | | pane 1 | pane 2 | pane 3| | | | | +----------+-----------+---------+
Use Windows
to create various windows and Triggers
to create their triggers.
Modifier and Type | Method and Description |
---|---|
Window<M,K,WV> |
setAccumulationMode(AccumulationMode mode)
Specify how a
Window should process its previously emitted WindowPane s. |
Window<M,K,WV> |
setEarlyTrigger(Trigger<M> trigger)
Set the early triggers for this
Window . |
Window<M,K,WV> |
setLateTrigger(Trigger<M> trigger)
Set the late triggers for this
Window . |
Window<M,K,WV> setEarlyTrigger(Trigger<M> trigger)
trigger
- the early triggerWindow
function with the early triggerWindow<M,K,WV> setLateTrigger(Trigger<M> trigger)
trigger
- the late triggerWindow
function with the late triggerWindow<M,K,WV> setAccumulationMode(AccumulationMode mode)
Window
should process its previously emitted WindowPane
s.
There are two types of AccumulationMode
s:
mode
- the accumulation modeWindow
function with mode
set as its AccumulationMode
.