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

    https://github.com/apache/flink/pull/3621#discussion_r108621618
  
    --- 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 --
    
    Here we should not through an exception, as it is just redundant, not 
wrong, right? So we could just ignore it. This will also simplify the code of 
the method.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to