Controlling Which Queries Output to a Downstream Channel If you specify more

Introduction to Oracle CQL 1-7

1.1.1.2 Relations

Time varying relation R is a mapping from the time domain to an unbounded bag of tuples to the schema of R. A relation is an unordered, time-varying bag of tuples: in other words, an instantaneous relation. At every instant of time, a relation is a bounded set. It can also be represented as a sequence of timestamped tuples that includes insertions, deletions, and updates to capture the changing state of the relation. Like streams, relations have a fixed schema to which all tuples conform. Oracle CEP supports both base and derived streams and relations. The external sources supply data to the base streams and relations. A base explicit stream is a source data stream that arrives at an Oracle CEP adapter so that time is non-decreasing. That is, there could be events that carry same value of time. A derived implicit streamrelation is an intermediate streamrelation that query operators produce. Note that these intermediate operators can be named through views and can therefore be specified in further queries. A base relation is an input relation. A derived relation is an intermediate relation that query operators produce. Note that these intermediate operators can be named through views and can therefore be specified in further queries. In Oracle CEP, you do not create base relations yourself. The Oracle CEP server creates base relations for you as required. When we say that a relation is a time-varying bag of tuples, time refers to an instant in the time domain. Input relations are presented to the system as a sequence of timestamped updates which capture how the relation changes over time. An update is either a tuple insertion or deletion. The updates are required to arrive at the system in the order of increasing timestamps. For more information, see: ■ Channels Representing Streams and Relations in the Oracle Complex Event Processing Developers Guide for Eclipse ■ Section 1.1.13, Time

1.1.1.3 Relations and Oracle CEP Tuple Kind Indicator

By default, Oracle CEP includes time stamp and an Oracle CEP tuple kind indicator in the relations it generates as Example 1–6 shows. Example 1–6 Oracle CEP Tuple Kind Indicator in Relation Output Timestamp Tuple Kind Tuple 1000: + ,abc,abc 2000: + hihi,abchi,hiabc 6000: - ,abc,abc 7000: - hihi,abchi,hiabc 8000: + hi1hi1,abchi1,hi1abc 9000: + ,abc,abc 13000: - hi1hi1,abchi1,hi1abc 14000: - ,abc,abc 15000: + xyzxyz,abcxyz,xyzabc 20000: - xyzxyz,abcxyz,xyzabc The Oracle CEP tuple kind indicators are: 1-8 Oracle Complex Event Processing CQL Language Reference ■ + for inserted tuple ■ - for deleted tuple ■ U for updated tuple indicated when invoking com.bea.wlevs.ede.api.RealtionSink method onUpdateEvent for more information, see Oracle Complex Event Processing Java API Reference.

1.1.2 Relation-to-Relation Operators

The relation-to-relation operators in Oracle CQL are derived from traditional relational queries expressed in SQL. Anywhere a traditional relation is referenced in a SQL query, a relation can be referenced in Oracle CQL. Consider the following examples for a stream CarSegStr with schema: car_id integer, speed integer, exp_way integer, lane integer, dir integer, and seg integer. In Example 1–7 , at any time instant, the output relation of this query contains the set of vehicles having transmitted a position-speed measurement within the last 30 seconds. Example 1–7 Relation-to-Relation Operation processor namecqlProcessorname rules view id=CurCarSeg schema=car_id exp_way lane dir seg[CDATA[ select distinct car_id, exp_way, lane, dir, seg from CarSegStr [range 30 seconds] ]]query rules processor The distinct operator is the relation-to-relation operator. Using distinct, Oracle CEP returns only one copy of each set of duplicate tuples selected. Duplicate tuples are those with matching values for each expression in the select list. You can use distinct in a select_clause and with aggregate functions. For more information on distinct, see: ■ Chapter 9, Built-In Aggregate Functions ■ select_clause::= on page 20-3

1.1.3 Stream-to-Relation Operators Windows

Oracle CQL supports stream-to-relation operations based on a sliding window. In general, S[W] is a relation. At time T the relation contains all tuples in window W applied to stream S up to T.