Windows

A window is a collection of rows, not unlike a database table.

While the "one-row-at-a-time" data stream model is very useful for picking out rows based on selection criteria and for performing basic intra-row calculations, it does not accommodate complex analysis of data involving multiple rows in a stream. In practice, it is often necessary for queries to deal with more than just the current row in the data stream.

For example, the average value of the stock trades that occurred in the last hour in a stock data trading data stream can only be calculated effectively if values from all of the rows for the last hour are available. This requires maintaining the state of more than one previously processed row. A principal way Sybase CEP maintains state is through the concept of windows.

A window can retain the state of many rows from a data stream (or from more than one data stream), enabling CCL to operate on all of these rows at the same time. Windows are filled with the incoming rows from a data stream, and rows are kept based on a variety of criteria:


Illustrating Windows in the Programmer's Guide

Windows are illustrated differently from streams. Where streams are depicted flowing from left to right on the page, with each row arranged vertically, windows will be shown much like a table of rows and columns. Data in the windows will be depicted as entering at the bottom of the illustration, so that the oldest rows in the table will be shown at the top. The columns of data in each row are presented left to right, with the timestamp in the first column on the left. Where rows have expired from a window, they will be shown grayed out and with a strike-through of all data values. This indicates that the row was once in the window but is no longer present because it has expired or has been deleted.



A window can be used as either a data source or destination for CCL queries. The state of a window is constantly changing. New rows from data streams flow into their associated windows and expire from the windows regularly, based on the window policies. With each change to the window, all continuous queries that access that window are executed and the results are passed along to subsequent streams and queries. These changes can then cause other queries to execute, in an ongoing and continuous process.


Created March 8, 2010. Send feedback on this help topic to Sybase Technical Publications: pubs@sybase.com