[ 
https://issues.apache.org/jira/browse/FLINK-30069?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Juntao Hu updated FLINK-30069:
------------------------------
    Description: 
When a pattern produces several matches with same priority, is it the expected 
behavior to keep only the first dequeued one?

E.G.

pattern: A.followedByAny(B).followedBy(C)

seq: a1, b1, b2, b3, c1

aftermatch strategy: skip_to_next

Potential matches (a1, b1, c1) (a1, b2, c1) (a1, b3, c1) reach final state at 
the same time and have the same priority, but (a1, b1, c1) is the first one in 
the queue, thus (a1, b2, c1) and (a1, b3, c1) will be dropped by skip_to_next 
strategy.

If it's by-design, I guess it relies on two things:
 * take must be the first transition for every state, if exists
 * priority queue is first-in-first-out for items with same priority

*UPDATE 17/Feb/23*

Example case is testNotFollowedByWithinAtEndAfterMatch() in 
[https://github.com/apache/flink/pull/21920] . If we change skip strategy to 
SKIP_TO_NEXT, the expected output is (a1, a2, a3, c1), (a2, a3, c1) and (a3, 
c1). If we run in JDK11, it works as expected, but after switching to JDK8 this 
case will fail with (a2, a3, c1) becoming (a2, c1). PriorityQueue.removeAll() 
is quite suspicous for breaking the order.

  was:
When a pattern produces several matches with same priority, is it the expected 
behavior to keep only the first dequeued one?

E.G.

pattern: A.followedByAny(B).followedBy(C)

seq: a1, b1, b2, b3, c1

aftermatch strategy: skip_to_next

Potential matches (a1, b1, c1) (a1, b2, c1) (a1, b3, c1) reach final state at 
the same time and have the same priority, but (a1, b1, c1) is the first one in 
the queue, thus (a1, b2, c1) and (a1, b3, c1) will be dropped by skip_to_next 
strategy.

If it's by-design, I guess it relies on two things:
 * take must be the first transition for every state, if exists
 * priority queue is first-in-first-out for items with same priority


> Expected prune behavior for matches with same priority
> ------------------------------------------------------
>
>                 Key: FLINK-30069
>                 URL: https://issues.apache.org/jira/browse/FLINK-30069
>             Project: Flink
>          Issue Type: Bug
>          Components: Library / CEP
>    Affects Versions: 1.15.3, 1.16.1
>            Reporter: Juntao Hu
>            Priority: Major
>
> When a pattern produces several matches with same priority, is it the 
> expected behavior to keep only the first dequeued one?
> E.G.
> pattern: A.followedByAny(B).followedBy(C)
> seq: a1, b1, b2, b3, c1
> aftermatch strategy: skip_to_next
> Potential matches (a1, b1, c1) (a1, b2, c1) (a1, b3, c1) reach final state at 
> the same time and have the same priority, but (a1, b1, c1) is the first one 
> in the queue, thus (a1, b2, c1) and (a1, b3, c1) will be dropped by 
> skip_to_next strategy.
> If it's by-design, I guess it relies on two things:
>  * take must be the first transition for every state, if exists
>  * priority queue is first-in-first-out for items with same priority
> *UPDATE 17/Feb/23*
> Example case is testNotFollowedByWithinAtEndAfterMatch() in 
> [https://github.com/apache/flink/pull/21920] . If we change skip strategy to 
> SKIP_TO_NEXT, the expected output is (a1, a2, a3, c1), (a2, a3, c1) and (a3, 
> c1). If we run in JDK11, it works as expected, but after switching to JDK8 
> this case will fail with (a2, a3, c1) becoming (a2, c1). 
> PriorityQueue.removeAll() is quite suspicous for breaking the order.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to