I have this pattern which I want to apply on a stream of events to detect two events that don't happen in order and they have one property which equall. However, the statement returns fine, but the results are repated and the eventBean gets the value just for the last event.
select * from event" +
" match_recognize (" +
" partition by robotId " +
" measures" +
" A.movementTask as m1, last(B.movementTask) as m2, C.movementTask as m3" +
" pattern (A B+ C)" +
" define" +
" A as A.movementTask.toVertex ='D', " +
" B as B.movementTask.toVertex != 'D', " +
" C as C.movementTask.toVertex ='D' " +
")"
The events:
movementTask=Task{fromVertex:'C', toVertex:'D'}
movementTask=Task{fromVertex:'A', toVertex:'B'}
movementTask=Task{fromVertex:'A', toVertex:'B'}
movementTask=Task{fromVertex:'J', toVertex:'D'}}
The results I get is like this:
{m1=Task{fromVertex:'J', toVertex:'D'}, m2=Task{fromVertex:'J', toVertex:'D'}, m3=Task{fromVertex:'J', toVertex:'D'}}
which is not correct, I should get:
{m1=Task{fromVertex:'C', toVertex:'D'}, m2=Task{fromVertex:'A', toVertex:'B'}, m3=Task{fromVertex:'J', toVertex:'D'}}
Make sure your code sends a new event objects for each distinct event. The code cannot use "set" or "put" but it must be a new object allocated anew for each event. I'm saying this because it seems that your event data gets mixed up as event objects get reused by your code.