siddhi icon indicating copy to clipboard operation
siddhi copied to clipboard

Issues with count occurrences in Pattern

Open pranjal0811 opened this issue 6 years ago • 3 comments
trafficstars

I have two queries -

Rule1 - "from every e1=inputStream[ name == 'A' ]<2:> within 1 min select 'rule1' as ruleId insert into outputStream"

Rule2 - "from every e1=inputStream[ name == 'A' ]<2> within 1 min select 'rule2' as ruleId insert into outputStream"

Both the above queries generate the same result. I get rule1 and rule2 both on each AA event.

In Rule1 I am expecting 2 or more A's within in 1 minute. If I pass AAAAAA within 1 minute I should get 1 signal, but I am getting 3 signals.

In Rule2 I am expecting exactly 2 A's within in 1 minute. If I pass AAAAAA within 1 minute I am getting 3 signals as expected.

Am I understanding anything wrong here?

pranjal0811 avatar Jul 16 '19 09:07 pranjal0811

@pranjal0811 What version of Siddhi are you using?

niveathika avatar Jul 19 '19 11:07 niveathika

@niveathika I am using the latest version 5.1.1

pranjal0811 avatar Jul 19 '19 13:07 pranjal0811

You are correct @pranjal0811

When you use an unbounded count e.g <2:> as the last element in the pattern. Siddhi will output the event when the count reaches 2, hence the behavior of <2> and <2:> will be the same in this case. But when the unbounded count element is used in the middle it will collect events till the next element in the pattern receives events.

I understand there is a natural expectation when you are using the unbounded count as the last element with the within clause, for it to collect till the end of time. We'll check on the possibility of supporting this.

suhothayan avatar Jul 23 '19 10:07 suhothayan