Github user dianfu commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4418#discussion_r130896034
  
    --- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/operator/AbstractKeyedCEPPatternOperator.java
 ---
    @@ -257,7 +289,32 @@ public void onEventTime(InternalTimer<KEY, 
VoidNamespace> timer) throws Exceptio
     
        @Override
        public void onProcessingTime(InternalTimer<KEY, VoidNamespace> timer) 
throws Exception {
    -           // not used
    +           NFA<IN> nfa = getNFA();
    +
    +           // emit the events in order
    +           for (IN event : sort(bufferedEvents.get())) {
    +                   processEvent(nfa, event, 
getProcessingTimeService().getCurrentProcessingTime());
    +           }
    +
    +           // remove all buffered rows
    +           bufferedEvents.clear();
    +
    +           updateNFA(nfa);
    +   }
    +
    +   private Iterable<IN> sort(Iterable<IN> iter) {
    +           if (comparator == null) {
    +                   return iter;
    +           } else {
    +                   // insert all events into the sort buffer
    +                   List<IN> sortBuffer = new ArrayList<>();
    --- End diff --
    
    Good advice. Updated.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to