M
- the type of the input MessageEnvelope
K
- the type of the key in the MessageEnvelope
in this MessageStream
.WV
- the type of the value in the WindowPane
.WM
- the type of the output.@InterfaceStability.Unstable public interface Window<M extends MessageEnvelope,K,WV,WM extends WindowPane<K,WV>>
MessageEnvelope
s in the 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 MessageEnvelope
s in the window and is called a WindowPane
.
A pane can include all MessageEnvelope
s collected for the window so far or only the new MessageEnvelope
s
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 of late data arrivals.
A Window
is defined as "keyed" when the incoming MessageStream
is first
partitioned based on the provided key, and windowing is applied on the partitioned 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 the Windows
APIs to create various windows and the Triggers
APIs to create triggers.
Modifier and Type | Method and Description |
---|---|
Window<M,K,WV,WM> |
setAccumulationMode(AccumulationMode mode)
Specify how a
Window should process its previously emitted WindowPane s. |
Window<M,K,WV,WM> |
setEarlyTrigger(Trigger<M> trigger)
Set the early triggers for this
Window . |
Window<M,K,WV,WM> |
setLateTrigger(Trigger<M> trigger)
Set the late triggers for this
Window . |
Window<M,K,WV,WM> setEarlyTrigger(Trigger<M> trigger)
trigger
- the early triggerWindow
function with the early triggerWindow<M,K,WV,WM> setLateTrigger(Trigger<M> trigger)
trigger
- the late triggerWindow
function with the late triggerWindow<M,K,WV,WM> setAccumulationMode(AccumulationMode mode)
Window
should process its previously emitted WindowPane
s.
There are two types of AccumulationMode
s:
mode
- the accumulation modeWindow
function with the specified AccumulationMode
.