2.4.2 Stream operation examples

This subsection shows examples of the stream data that is output when each type of stream operation is used. Note that the examples here show cases in which PARTITION BY stock-name ROWS 1 is specified in the window operation.

Organization of this subsection
(1) Example of outputting the tuples that were added to the output relation (ISTREAM)
(2) Example of outputting the tuples that were deleted from the output relation (DSTREAM)
(3) Example of outputting all tuples in the output relation at a specified time interval (RSTREAM)

(1) Example of outputting the tuples that were added to the output relation (ISTREAM)

The following figure shows the output relation and an example of the result stream data when ISTREAM is specified.

Figure 2-14 Output relation and resulting stream data when ISTREAM is specified

[Figure]

When a tuple is added to the output relation, the corresponding tuple is output to the result stream data. In this example, when the tuple (Stock A, 1.0) is added to the output relation at time t1, the tuple (Stock A, 1.0) is also output to the result stream data at time t1. Then, when tuples are added at time t2 or t3, they are also output to the result stream data.

When the tuple (Stock A, 0.9) is added at time t4, the tuple (Stock A, 0.9) which was added at time t2 is deleted, so there is no change in the relation. Consequently, nothing is output to the result stream data.

(2) Example of outputting the tuples that were deleted from the output relation (DSTREAM)

The following figure shows the output relation and an example of the result stream data when DSTREAM is specified.

Figure 2-15 Output relation and result stream data when DSTREAM is specified

[Figure]

When a tuple is deleted from the output relation, the tuple is output to the result stream data. In this example, when the tuple (Stock A, 1.0) is deleted from the output relation at time t2, it is also output to the result stream data.

When the tuple (Stock A, 0.9) is deleted at time t4, the tuple (Stock A, 0.9) is added at the same time, so there is no change in the relation. Consequently, nothing is output to the result stream data just like when ISTREAM was specified.

(3) Example of outputting all tuples in the output relation at a specified time interval (RSTREAM)

The following figure shows the output relation and an example of the result stream data when RSTREAM is specified.

Figure 2-16 Output relation and result stream data when RSTREAM is specified

[Figure]

Tuples in the output relation are output to the result stream data at 1-second intervals. At time tA, only the tuple (Stock A, 1.0) is in the output relation, and therefore only it is output to the result stream data. A second later at time tB, the tuples in the output relation consist of (Stock A, 0.9) and (Stock B, 1.1) and therefore they are output to the result stream data.

Thereafter, the content of the output relation is output to the result stream data every second.