2.3.2 Example of a linking process

This subsection shows an example of extracting the result of linking two types (s1 and s2) of input relations for each stock name.

An example of a CQL definition is described below.

REGISTER QUERY q
  SELECT s1.stock-name, s1.rate-of-price-increase, s2.stock-name, s2.GC-flag
  FROM s1[PARTITION BY s1.stock-name ROWS 1],
       s2[PARTITION BY s2.stock-name ROWS 1]
  WHERE s1.stock-name=s2.stock-name;

The following figure shows examples of input and output relations when this CQL is executed.

Figure 2-11 Example of a linking process

[Figure]

The horizontal axis indicates time, which advances from left to right. Times t1 to t6 indicate the time at which tuples arrived. The tuples in input relation s1 consist of a stock name and a rate of price increase, while the tuple in s2 consists of a stock name and a GC flag. The value of the GC flag is either DC (Dead Cross) or GC (Golden Cross).

In this example, tuples are linked based on the stock name and the result is output.

At time tA, a tuple (Stock A, 1.0) and a tuple (Stock A, GC) are in input relations s1 and s2, respectively. As a result of linking these tuples based on the stock name, a tuple (Stock A, 1.0, Stock A, GC) is put in the output relation.

Likewise, at time tB, the tuples (Stock A, 1.2) and (Stock B, 1.3) are in input relation s1, while the tuples (Stock A, DC) and (Stock B, GC) are in input relation s2. As a result of linking these tuples based on the stock name, the tuples (Stock A, 1.2, Stock A, DC) and (Stock B, 1.3, Stock B, GC) are put in the output relation.

In this way, when a linking process is performed at a specified time, the results extracted to the output relation as tuples depend on the lifespan of the tuples in the input relation.