Sequences
from <event-regular-expression-of-streams> within <time>
select <attribute-name> {, <attribute-name>}
insert into <stream-name>
With patterns, there can be other events in between the events that match the pattern condition. In contrast, sequences must exactly match the sequence of events without any other events in between.
1. Sequence processing uses one or more streams.
2. As input, it takes a sequence of conditions defined in a simple regular expression fashion.
3. The events of the input streams should be assigned names in order to uniquely identify these events when constructing the query projection.
4. It generates the output event stream such that any event in the output stream is a collection of events arrived from the input streams that exactly matches the order defined in the sequence.
5. For a sequence, the output attribute must be named using the ‘as’ keyword, and it will be used as the output attribute name.
When “within <time>” is used, just like with patterns, Siddhi will output only the events that are within that time of each other.
After one or more occurrence of infoStock event with action == "buy", the query matches StockExchangeStream events with maximum of one event with price between 70 and 75 and one event with price >= 75
from a1 = infoStock[action == "buy"]+,
b1 = StockExchangeStream[price > 70]?,
b2 = StockExchangeStream[price >= 75]
select a1[0].action as action, b1.price as priceA, b2.price as priceBJoin
insert into StockQuote
Following Regular Expressions are supported
* Zero or more matches (reluctant).
+ One or more matches (reluctant).
? Zero or one match (reluctant).
or or
Similar to the pattern’s count operation, the ‘*’ and ‘+’ regex operators also output many events occurrences. Hence we have to refer these events using square brackets to access a specific occurrence of that event. In the above example, a1[0] refers to the first matching event arrived via the infoStock stream.