Windowing library

The windowing library is a set of classes in the Streams Processing Language (SPL) Operator Runtime C++ API and the SPL Java Operator API. This library provides consistent window policy semantics across operators and simplifies primitive operator implementation when you need windows that follow SPL window semantics.

SPL offers both tumbling and sliding windows. Both types of windows keep all the incoming data in memory until its tuple eviction policy triggers. Use the SPL support for windows when the function required by the primitive operator can be built with the semantics that are provided by SPL window constructs.

One example operator from the SPL Standard Toolkit that uses the windowing library and syntax is the Aggregate operator. An example operator that buffers recently received tuples but that does not use the windowing library and syntax is the DeDuplicate operator. This action occurs because this operator has different eviction and trigger semantics than the ones provided by SPL. This operator needs to maintain only unique tuples and discards all repeated tuples that are received within a time window.

With the windowing library, developers can specify different eviction and trigger policies but can implement the event handling actions independently of the window policy details. There are a few differences when you implement primitive operators in C++ and Java that take advantage of the SPL window clause.

In the C++ implementation, developers have no obligation to use the window library if they use a TumblingWindow or a SlidingWindow. They are free to use the SPL Operator Code Generation API just to get the specified window policy for an operator instance. In addition, developers can check for valid window configurations during code generation time. They can generate code using other containers, if they implement the window interface provided by the library. They must, however, build a windowing class which extends SPL::BaseWindow.

For event-time applications, developers must use the TimeIntervalWindow implementation provided by the C++ library. TimeIntervalWindow instances are automatically notified by the run time when the operator's watermark has advanced. Developers can check for valid window configurations during runtime by checking the TimeIntervalWindowOptions object passed to the window constructor.

It is strongly recommended, however, that developers use the default Data and Storage template types provided by the C++ window library, which provide checkpointing support inside and outside consistent regions.

In the Java implementation, developers must use the window library. This action can be achieved by registering a class that implements com.ibm.streams.operator.window.StreamWindowListener<T> that handles events that are generated by a window (com.ibm.streams.operator.window.StreamWindow<T>). This use is required because Java operators are not based on code generation. As a result, windows are automatically managed by the run time to ensure SPL window semantics. Developers can check for valid window configurations during run time by checking the window policy that is associated to an input port.