0

I have the following query:

from stream1
select count() as item insert into newStream;

Is it possible to restart the count() function of a stream?

If not, how can I circumvent this? If possible.

Community
  • 1
  • 1

1 Answers1

2

If you use count() or any other aggregate function without a window, there's no way to reset the events that get accumulated within that aggregator. For example if you use a window like below, it will reset the counter after receiving 10 events.

from stream1#window.lengthBatch(10)
select count() as item insert into newStream;

However, If you need to reset the counter by sending an parameter to it, (i.e count(bool reset)) you may have to write your own custom aggregate function as described in the following documentation.

  • I am using a window now. making from stream1#window.time(5 min) select count() as item isnert into newStream; but now this gives me only the first 5 minutes. Not a continuos time window. – JoaoFilipeClementeMartins May 03 '17 at 22:04
  • Window 'time' is continuous. It's a sliding time window that holds events that arrived during the last windowTime period at a given time, and gets updated for each event arrival and expiry. If you want to process events every 5 mins, as a batch, you should use window 'timeBatch". It's a batch (tumbling) time window that holds events that arrive during windowTime periods, and gets updated for each windowTime. Refer documentation : https://docs.wso2.com/display/CEP420/Inbuilt+Windows – Ruwini Wijesiri May 10 '17 at 13:09