Join operations and lots
The principle of updating the state of a query in a single operation without the intermediate state being visible is most relevant for join operations. The two diagrams that follow illustrate how a cross-join behaves when several events arrive in a single lot.
In the diagrams, the items on the left side of the join are represented by the numbered items that come in from the left side and the items on the right side of the join are represented by the lettered items that come in from the top. Each square in the grid can be a joined event. In both diagrams, the results of the join before the lot arrives are mostly highlighted in blue. The items joined after the lot arrives are mostly highlighted in teal. The relevant stream query in both examples is:
from a in sA retain 3
from b in sB retain 3
select C(a, b);
The complete set of values in the table represents all of the combinations of items from sA and items from sB that could possibly be generated by the join when considering alternative ways of ordering the sA and sB items arriving in the lot. In general, there is no particular ordering of the sA and sB items that is superior (more meaningful) than all other orderings. Thus, when considering the transitions, there is no preferred path from the initial window content to the final window content. Hence, it is considered that the correct output for the join is achieved by taking the difference between the initial window content and the final window content, ignoring any intermediate states.
In the first diagram, there are nine joined events before the lot arrives. These are represented by the seven blue squares and the two orange squares. Two items, 4 and 5, arrive on sA and displace items 1 and 2. Also, one item, d, arrives on sB. and displaces item a. The result is nine joined events after the lot arrives, of which two were there before (represented by the two orange squares, and seven are new, represented by the teal squares. A non-aggregating query that outputs the istream (as given above) would return the seven new items (shown in teal). If, instead, the query was selecting the rstream then it would return the seven items that are no longer a result of the join (shown in blue).
In the second example, there are again nine joined events before the lot arrives. These are represented by the nine blue squares. Four items, 4, 5, 6, and 7 arrive on sA and displace items 1, 2, and 3. Because this is a retain 3 window, item 4, as the oldest item in the lot, never makes it into the window. Also, items d, e, f, and g arrive on sB, which displaces items a. b, and c, and again, because it is a retain 3 window, item d never appears in the window. After the lot arrives, the result is nine new joined events, which are represented by the teal squares.
Since there are no joined events that are present both before the lot arrives and after the lot arrives all nine events that were previously the result of the join would be returned by a query selecting the remove stream of this join. The nine new events are output by the query that selects the input stream. No events containing either '4' or 'd' are ever visible as a result of the query even though both values were present on one of the inputs.
Copyright © 2013
Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.