This information applies to earlier Siddhi extension versions. For the latest information about Siddhi extensions, see Siddhi Extensions
Skip to end of metadata
Go to start of metadata

The RDBMS event table has been tested with the following databases: 

  • MySQL
  •  H2
  •  Oracle
Syntax

@from(eventtable = <eventtable type>, [<property name> =  <property value>]*)

[@IndexBy(<attribute name>)]?

define table <table name> ([<attribute name> <attribute type>]+);
Extension TypeEventTable
DescriptionAn event table can be backed with an RDBMS event store using the From annotation. This annotation also assigns the data source or the connection instructions to the event table. The RDBMS table name can be different to the event table name defined in Siddhi, and Siddhi always refers to the defined event table name. However the defined event table name cannot be same as an already existing stream name because the Siddhi Query Language considers both to be the same syntactically. 
Parameters
  • eventable type: The constant value that defines the type of the event table. For Hazlecast event table, use rdbms.
  • property name: The rdbms data source connection configuration properties. The available properties are as follows.
    • datasource.name: The datasource name is injected to the Siddhi engine by the CEP/DAS. This is not required To configure datasources in CEP/DAS see Managing Datasources in the WSO2 Administration Guide.
    • table.name: The reference table name defined in the datasource.
    • jdbc.url: The jdbc url for the databases that are not registered as datasources.
    • driver.name: The jdbc driver name for the databases that are not registered as datasources.
    • username: The username for the databases that are not registered as datasources.
    • password: The password for the databases that are not registered as datasources.
    • cache: Several caches can be used with RDMBS backed event tables in order to reduce I/O operations and improve their performance. Currently all cache implementations provides size-based algorithms. The supported cache implementations are as follows.
      • Basic: Events are cached in a FIFO manner where the oldest event is dropped when the cache is full.
      • LRU (Least Recently Used): The least recently used event is dropped when the cache is full.
      • LFU (Least Frequently Used): The least frequently used event is dropped when the cache is full.
    • cache.size: The size of the cache. If the element is not assigned, 4096 is assigned as the cache size by default.
  • bloom.filters: This property enables/disables the bloom filters. A Bloom Filter is an algorithm or an approach that can be used to perform quick searches. If you apply a Bloom Filter to a data set and carry out an isAvailable check on that specific Bloom Filter instance, an accurate answer is returned if the search item is not available. This allows the quick improvement of updates, joins and isAvailable checks.
  • property value: This defines values for all the properties.
  • table name: This defines the name of the table.
  • attribute name: This defines the name of the table column.
  • attribute type: This defines the type of the table column.
ReturnN/A
Example
  • The following creates an event table named RoomTypeTable with two attributes named roomNo (an INT attribute) and type (a STRING attribute), backed by a MySQL table named RoomTable from the cepdb database located at localhost:3306 with root as both the username and password.

    @From(eventtable='rdbms', datasource.name='AnalyticsDataSource', table.name='RoomTable')
    define table RoomTypeTable (roomNo int, type string);
  • The following creates an event table named RoomTypeTable with two attributes named roomNo (an INT attribute) and type (a STRING attribute), backed by an RDBMS table using he LRU caching algorithm for caching 3000 events. 

    @From(eventtable='rdbms', datasource.name='AnalyticsDataSource', table.name='RoomTable', cache='LRU', cache.size='3000')
    define table RoomTypeTable (roomNo int, type string);
  • The following example shows how to include Bloom Filters in an event table update query.

    define stream StockStream (symbol string, price float, volume long);
    define stream CheckStockStream (symbol string, volume long);
    @from(eventtable = 'rdbms' ,datasource.name = 'cepDB' , table.name = 'stockInfo' , bloom.filters = 'enable')
    define table StockTable (symbol string, price float, volume long);
      
    @info(name = 'query1')
    from StockStream
    insert into StockTable ;
      
    @info(name = 'query2')
    from CheckStockStream[(StockTable.symbol==symbol) in StockTable]
    insert into OutStream;

     


For more information about In-memory event tables, see Sample 0106 - Using in-memory event tables.

For more information about RDBMS event tables, see Sample 0107 - Using RDBMS event tables.

  • No labels