Specifications

Application Development CHAPTER 8 159
Count windows are completely different from the other window types because the size of
the windows is variable. When you create windows, you provide a parameter n as a count of
events to fulll within a window. For example, assume n is 2 as shown in Figure 8-5. The rst
window starts when the rst event starts and ends when the second event starts, because a
count of 2 events fullls the specication. The second event also resets the counter to 1 and
starts a new window. The third event increments the counter to 2, which ends the second window.
e1
e2
e1
e2
e2
e3
Input
events
Time
e3
Count
windows
(n=2)
FIGURE 8-5 Count windows
Aggregations
You cannot perform aggregation operations on event streams directly; instead you must rst
create a window to group data into periods of time that you can then aggregate. You then
create an aggregation as a method of the window and, for all aggregations except Count, use
a lambda expression to assign the result to a eld.
StreamInsight supports the following aggregation functions:
Avg
Sum
Min
Max
Count