IBM Streams 4.2

Window clause

A window is a logical container for tuples recently received by an input port of an operator.

Figure 1. Window types
This figure displays the different window types in the window clause.

Some relational operators rely on windows for their operation. For example, in Join(A;B), when a tuple arrives on port A, SPL updates the window on port A and matches the new tuple against each tuple in the window on port B.

The syntax for the window clause is:
opInvokeWindow ::= ID ‘:' ( ‘tumbling' ‘,' evictionSpec
                          | ‘sliding' ‘,' evictionSpec ( ‘,' triggerSpec )? )
                          ( ‘,' ‘partitioned' (‘,' partitionEvictionSpec)? )? ‘;'

The following example illustrates different kinds of windows on different input ports.

composite Main {
 graph
    stream<float32 c> C = Beacon() {}
    stream<int32 i> X = Beacon() {}
    stream<int32 i> Y = Beacon() {}
    stream<float32 c> A = MyOperator(C; X, Y as D) {
      window C : sliding, time(10), count(5);
             D : tumbling, delta(i, 10);
    }
}

Port C uses a time-based sliding window over the last 10 seconds, which triggers the operator's behavior after every 5 tuples. Port D, which interleaves tuples from streams X and Y, uses an attribute-delta based tumbling window, where attribute i in the oldest and newest tuple differs by no more than 10. Attribute names are scoped by the port label in the window clause: for example, i corresponds to D.i. All other expressions in windows must be compile-time constants.