Excerpt | ||
---|---|---|
| ||
Siddhi Wiki for patitions |
...
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 ;
...
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