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

Unknown macro: {next_previous_link3}
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

« Previous Version 7 Current »

Note: A single partition definition can be used by multiple queries.

<define-partition> ::= define partition <partition-id> by <partition-type> {, <partition-type>}*
<partition-type> := <attribute-name> | range <condition> as <partition-key> {, <attribute-name> | range <condition> as <partition-key>}*

All partitions must be defined before using it in a query and such a definition must have a unique id.

Following example shows a sample partition definition;

Defining a partition with an ID 'StockSymbol' which will partition any query that uses this particular partition definition by the 'symbol' attribute of 'stockStream' .

define partition StockSymbol by  stockStream.symbol ;

Currently CEP supports two types of partitioning.

Variable Paritioning

Partitions are broken up according to a pre-defined variable. The example above shows a variable partitioning for the variable 'symbol' in 'stockStream'.

Range Partitioning

Partitions are broken up according to the range of a specified variable. The partition key for a particular range must be provided.

Following example shows a sample definition for range partitioning.

Defining a partition with an ID 'StockVolume' which will partition any query that uses this particular partition definition by the range definitions;
namely if volume is less than 10 it will be sent to the partition 'SMALL', if it is between 10 and 100, then it would be sent to 'MEDIUM' partition, else
it would go to partition identified by key 'LARGE'. 

define partition StockVolume by
    range volume < 10 as 'SMALL',  
    range volume >= 10 and volume <= 100 as 'MEDIUM',
    range volume > 100 as 'LARGE' ;

For range partitioning, the partition keys must be specified at the definition.

To apply partitioning to a particular query, use the 'partition by' keyword to specify the partition definition at the end of the query. Following example partitions by stock symbol as in the partition definition at the top of the page.

from stockStream[price >= 20]#window.length(50) 
select symbol, avg(price) as avgPrice

insert into StockQuote for expired-events 
partition by StockSymbol 

  • No labels