Table and Store
Provides introduction to in-memory tables and database backed stores that can be used to store events.
For information on various types of stores, primary keys, indexes, and caching, refer examples related to Event Store Integration and Siddhi query guide.
define stream TemperatureStream (
sensorId string, temperature double);
define table TemperatureLogTable (
sensorId string, roomNo string, temperature double);
@store(type="rdbms",
jdbc.url="jdbc:mysql://localhost:3306/sid",
username="root", password="root",
jdbc.driver.name="com.mysql.jdbc.Driver")
define table SensorIdInfoTable (
sensorId string, roomNo string);
@info(name = 'Join-query')
from TemperatureStream as t join SensorIdInfoTable as s
on t.sensorId == s.sensorId
select t.sensorId as sensorId, s.roomNo as roomNo
t.temperature as temperature
insert into TemperatureLogTable;
|
Defines |
|
Defines in-memory |
|
Store annotation to back |
|
Defines |
|
|
|
|
|
Selects |
Event at table and store
When SensorIdInfoTable
table contains a recode ['aq-14'
, '789'
], and when an event with values ['aq-14'
, 35.4
] is sent to TemperatureStream
stream.
The event will get converted and added to the TemperatureLogTable
table as below.
['aq-14'
, '789'
, 35.4
]
Retrieving values from tables and stores
The stored values can be retrieved by join tables and stores with the streams as in the Join-query
depicted in the example, or using on-demand queries.
The data in TemperatureDetailsTable
can be retrieved via on-demand queries as below, using the On Demand Query REST API or by calling query()
method of SiddhiAppRuntime
.
from TemperatureDetailsTable
select *