how can i use wso2 siddhiQL Cache data?

135 views Asked by At

My question is like this, I define a data source access to real-time data per second (has), I will for this batch of data per hour for an average calculation, and then to have this group of data per hour average accumulative sum, finally put the cumulative value of an hour, to another data source.Such as the mean value is 10 1 hour, I will give 10 to a data source, the second hour average is 20, then I will add 1 hour on average 10 output 30, so on, to the end of the 24 hours a day, the second day in from the first hour is calculated.Problem now is how can I, cache the last time I calculate the cumulative values, how to solve the similar problem? eg: enter image description here

Just like the picture above, in the column of the avg data is I through instream_ # window.externalTimeBatch (datetime, 1 hour) can get, at the back of the column is the result of the output per hour, I think. like this:enter image description here

Every compute a result is output

1

There are 1 answers

0
yeahliu On BEST ANSWER

You can use Event Table to cache the data in relation database like postgres/mysql/oracle.

Fist define table from database :

@From(eventtable='rdbms', datasource.name='db_event', table.name='_tag_time_value')
define table tEvent (tag string, datetime long , value double);

and if the stream time reach , you can insert overwrite 0.0 into the event table