[ 
https://issues.apache.org/jira/browse/FLINK-6165?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15946936#comment-15946936
 ] 

ASF GitHub Bot commented on FLINK-6165:
---------------------------------------

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

    https://github.com/apache/flink/pull/3621#discussion_r108649205
  
    --- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Pattern.java
 ---
    @@ -267,6 +267,76 @@ public int getTimes() {
        }
     
        /**
    +    * Works in conjunction with {@link Pattern#zeroOrMore()}, {@link 
Pattern#oneOrMore()} or {@link Pattern#times(int)}.
    +    * Specifies that any not matching element breaks the loop.
    +    *
    +    * <p>E.g. a pattern like:
    +    * <pre>{@code
    +    * Pattern.<Event>begin("start").where(new FilterFunction<Event>() {
    +    *      @Override
    +    *      public boolean filter(Event value) throws Exception {
    +    *          return value.getName().equals("c");
    +    *      }
    +    * })
    +    * .followedBy("middle").where(new FilterFunction<Event>() {
    +    *      @Override
    +    *      public boolean filter(Event value) throws Exception {
    +    *          return value.getName().equals("a");
    +    *      }
    +    * })
    +    * }<b>.oneOrMore(true).consecutive()</b>{@code
    +    * .followedBy("end1").where(new FilterFunction<Event>() {
    +    *      @Override
    +    *      public boolean filter(Event value) throws Exception {
    +    *          return value.getName().equals("b");
    +    *      }
    +    * });
    +    * }</pre>
    +    *
    +    * <p>for a sequence: C D A1 A2 A3 D A4 B
    +    *
    +    * <p>will generate matches: {C A1 B}, {C A1 A2 B}, {C A1 A2 A3 B}
    +    *
    +    * <p><b>NOTICE:</b> This operator can be applied only when either 
zeroOrMore,
    +    * oneOrMore or times was previously applied!
    +    *
    +    * <p>By default a relaxed continuity is applied.
    +    *
    +    * @return pattern with continuity changed to strict
    +    */
    +   public Pattern<T, F> consecutive() {
    +           switch (this.quantifier) {
    +
    +                   case ZERO_OR_MORE_EAGER:
    +                           this.quantifier = 
Quantifier.ZERO_OR_MORE_EAGER_STRICT;
    +                           break;
    +                   case ZERO_OR_MORE_COMBINATIONS:
    +                           this.quantifier = 
Quantifier.ZERO_OR_MORE_COMBINATIONS_STRICT;
    +                           break;
    +                   case ONE_OR_MORE_EAGER:
    +                           this.quantifier = 
Quantifier.ONE_OR_MORE_EAGER_STRICT;
    +                           break;
    +                   case ONE_OR_MORE_COMBINATIONS:
    +                           this.quantifier = 
Quantifier.ONE_OR_MORE_COMBINATIONS_STRICT;
    +                           break;
    +                   case TIMES:
    +                           this.quantifier = Quantifier.TIMES_STRICT;
    +                           break;
    +                   case ZERO_OR_MORE_COMBINATIONS_STRICT:
    +                   case ONE_OR_MORE_EAGER_STRICT:
    +                   case ONE_OR_MORE_COMBINATIONS_STRICT:
    +                   case ZERO_OR_MORE_EAGER_STRICT:
    +                   case TIMES_STRICT:
    +                           throw new MalformedPatternException("Strict 
continuity already applied!");
    --- End diff --
    
    Ok after your second comment I changed just the message of the exception
    
    As a side note I was considering changing the quantifier field to 
EnumSet<QuantifierProperty> but then we would not have a clearly defined valid 
combinations of properties (we would have to maintain it at the API level). 
This method though would be as simple as .add(QuantifierProperty.STRICT)
    
    @kl0u What do you think?


> Implement internal continuity for looping states.
> -------------------------------------------------
>
>                 Key: FLINK-6165
>                 URL: https://issues.apache.org/jira/browse/FLINK-6165
>             Project: Flink
>          Issue Type: New Feature
>          Components: CEP
>            Reporter: Dawid Wysakowicz
>            Assignee: Dawid Wysakowicz
>
> We should be able to specify an internal continuity for a looping state. The 
> API could look like: {{zeroOrMore().consecutive()}}. So that we have a 
> continuity up to the first element of a loop and between elements in the loop.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to