Storage Integration
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_link3' is unknown.

Storage Integration

This section explains how to configure WSO2 Siddhi tables in which the data analyzed by WSO2 SP can be saved. 

By default, a Siddhi table definition would refer to an in-memory table. If the tables are to be created in an external database, the datasource details must be specified as elaborated under the 'Referring to datasources' section.

Referring to datasources

The @store annotation allows to refer to extenal datasources. A datasource could be referred to as in the following example.

@store(type="rdbms", jdbc.url="jdbc:mysql://localhost:3306/sp_samples", username="root", password="root", jdbc.driver.name="com.mysql.jdbc.Driver")
define table StockTable (symbol string, price float, volume long);

Supported store implementations in Stream Processor 4.0 include the following:

  • RDBMS store (which in turn supports the following)

    • H2

    • MySQL

    • Oracle Database

    • MS SQL Server

    • PostgreSQL

    • IBM DB2

  • Apache HBase

  • Apache Solr

  • MongoDB

A datasource could also be defined externally, and referred to from several siddhi applications as described under Connecting to Stores section.

Adding primary keys

Attribute(s) within the event stream for which the event table is created can be specified as the primary key for the table. The purpose of primary key is to ensure that the value for a selected attribute is unique for each entry in the table. This prevents the duplication of entries saved in the table. 

Primary keys are configured via the @PrimaryKey annotation. Only one @PrimaryKey annotation is allowed per event table.

When several attributes are given within Primary key annotation (e.g @PrimaryKey( 'key1', 'key2')), those attributes would act as a composite primary key.

Syntax

@PrimaryKey('<attribute_1>')
define table <event_table> (<attribute_1> <attribute_type>, <attribute_2> <attribute_type>, <attribute_3> <attribute_type>);

Example

@PrimaryKey('symbol')
define table StockTable (symbol string, price float, volume long);

The above configuration ensures that each entry saved in the StockTable event table should have a unique value for the symbol attribute because this attribute is defined as the primary key.

Adding indexes

An attribute within the event stream for which the event table is created can be specified as the primary key for the table. This allows the entries stored within the table to be indexed by that attribute.

Indexes are configured via the @Index annotation.

An event table can have multiple attributes defined as index attributes. However, only one @Index annotation can be added per event table.

Syntax

To index by a single attribute:

@Index('<attribute_1>')
define table <event_table> (<attribute_1> <attribute_type>, <attribute_2> <attribute_type>, <attribute_3> <attribute_type>);

To index by multiple attributes:

@Index('<attribute_1>''<attribute_2>')
define table <event_table> (<attribute_1> <attribute_type>, <attribute_2> <attribute_type>, <attribute_3> <attribute_type>);

Example

@Index('symbol')
define table StockTable (symbol string, price float, volume long);

The above configuration ensures that the entries stored in the StockTable event table are indexed by the symbol attribute.

More information on Storage Integration is provided under the following sections

  1. Configuring Event Tables to Store Data
  2. Connecting to Stores
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.