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 )? 
                          | ‘timeInterval' ‘,' intervalDuration ( ‘,' optionalParameter )? )
                          ( ‘,' ‘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<timestamp et, int32 i> Z = Beacon() {}
   stream<float32 c> A = MyOperator(C; X, Y as D; Z as T) {
     window C : sliding, time(10), count(5);
            D : tumbling, delta(i, 10); 
            T : timeInterval, intervalDuration(60.0), creationPeriod(10.0), discardAge(3600.0);
  }
}

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. Port T uses a timeInterval window with intervals of 1 minute (60 seconds) duration between the lower and upper interval endpoints and a duration of 10 seconds between adjacent intervals. Tuples which arrive later (with respect to the current watermark) than the discarding age of 1 hour (3600 seconds) are ignored. Closed panes are deleted. 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.