Using dynamic expressions in windows

A window definition can contain some or all of the following:

A partition key expression

The window duration, size or both duration and size

An every batch period or size

The key for a with unique clause

The following table shows when the correlator evaluates each of these:

Window Definition | Description |

retain n | The correlator evaluates n every time an item arrives on the stream. The correlator uses the new value of n to calculate what should be in the window. |

retain n every m | The correlator stores incoming items until the current value of m is satisfied. When m is satisfied, the correlator evaluates both n and m. The correlator uses the new value of n to calculate what should be in the window, including the stored items. Because m is evaluated only after it has been satisfied, meeting that condition is always based on the old value of m. |

within d | The correlator evaluates d every time an item arrives on the stream and every time an item is due to be removed from the window. The correlator uses the new value of d to calculate what should be in the window. |

within d every p | The correlator stores incoming items until p seconds have elapsed. When p seconds have elapsed, the correlator evaluates p and d only if there are any items in the window or stored. The correlator uses the new value of d to calculate what should be in the window, including stored events. The correlator uses the new value of p to determine the next time the window can change. If there are no items in the window or waiting to enter the window then, for efficiency, the correlator does not evaluate p. When the correlator evaluates p, it is always based on the old value of p. |

...retain n | If a within or within every window definition also specifies retain, the correlator evaluates n whenever the window content can change. The correlator uses the new value of n to calculate what should be in the window. If the window definition specifies every, the window content can change only when p is satisfied. Otherwise, the window content can change when an item arrives on the stream and when an item is due to be removed from the window. |

partition by k1[, k2]... | If the window definition specifies a timed every p clause, the correlator evaluates each partition expression when p seconds have elapsed. Otherwise, the correlator evaluates each key expression when an item arrives on the stream. The correlator uses the new value of each key expression to calculate what should be in each partition. |

with unique w | The correlator evaluates w once for each item whenever that item is about to enter the window. If there is an every clause, an item can enter the window only when m or p is satisfied. Otherwise, an item can enter the window when it arrives on the stream. |