This documentation is for WSO2 CEP 2.1.0. View the home page of the latest release.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

from <stream>#<window> [unidirectional]
      join <stream>#<window> [unidirectional]
[on <condition>] [within <time>]
insert [<output-type>] into <stream-name> ( {<attribute-name>}| ‘*’)

  1. Join takes two streams as the input
  2. Each stream must have an associated window
  3. It generates the output events composed of one event from each stream
  4. With “on <condition>” Siddhi joins only the events that matches the condition
  5. With “within <time>”, Siddhi joins only the events that are within that time of each other

Following example shows a join query.

Outputs the matching events via JoinStream from last 2000 TickEvent and the NewsEvent that have arrived within 500 msec.

from TickEvent[symbol==’IBM’]#window.length(2000) join
NewsEvent#window.time(500)
insert into JoinStream *

Join can be in multiple forms

1. join - inner join
2. [((left|right|full) outer) | inner] join - only inner join is supported in the current version

When we join two streams, the events arriving at either stream will trigger a joining process. Siddhi also supports a special ‘unidirectional’ join. Here only one stream (the stream defined with the ‘unidirectional’ keyword ) will trigger the joining process.

Following shows a sample unidirectional join query

When an event arrives at the TickEvent that will be matched with all NewsEvents that have arrived within 500 msec, and if the TickEvent’s symbol == NewsEvent’s company, the output event will be generated and sent via JoinStream.

from TickEvent[symbol==’IBM’]#window.length(2000) as t unidirectional
join NewsEvent#window.time(500) as n
on t.symbol == n.company
insert into JoinStream *

Here ‘join’ only triggered when events arrives in TickEvent stream.
When no projection is given or when ‘*’ is used, the output stream attributes will contain both the input events attributes, and the output attributes will be named as <input-stream-name>_<attribute> to maintain uniqueness.

 

  • No labels