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

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

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

    https://github.com/apache/flink/pull/3761#discussion_r113378455
  
    --- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Pattern.java
 ---
    @@ -162,130 +186,114 @@ public int getTimes() {
        }
     
        /**
    -    * Appends a new pattern operator to the existing one. The new pattern 
operator enforces strict
    -    * temporal contiguity. This means that the whole pattern only matches 
if an event which matches
    -    * this operator directly follows the preceding matching event. Thus, 
there cannot be any
    -    * events in between two matching events.
    +    * Appends a new pattern to the existing one. The new pattern enforces 
strict
    +    * temporal contiguity. This means that the whole pattern sequence 
matches only
    +    * if an event which matches this pattern directly follows the 
preceding matching
    +    * event. Thus, there cannot be any events in between two matching 
events.
         *
    -    * @param name Name of the new pattern operator
    -    * @return A new pattern operator which is appended to this pattern 
operator
    +    * @param name Name of the new pattern
    +    * @return A new pattern which is appended to this one
         */
        public Pattern<T, T> next(final String name) {
                return new Pattern<T, T>(name, this);
        }
     
        /**
    -    * Appends a new pattern operator to the existing one. The new pattern 
operator enforces
    -    * non-strict temporal contiguity. This means that a matching event of 
this operator and the
    +    * Appends a new pattern to the existing one. The new pattern enforces 
non-strict
    +    * temporal contiguity. This means that a matching event of this 
pattern and the
         * preceding matching event might be interleaved with other events 
which are ignored.
         *
    -    * @param name Name of the new pattern operator
    -    * @return A new pattern operator which is appended to this pattern 
operator
    +    * @param name Name of the new pattern
    +    * @return A new pattern which is appended to this one
         */
        public FollowedByPattern<T, T> followedBy(final String name) {
                return new FollowedByPattern<T, T>(name, this);
        }
     
        /**
    -    * Starts a new pattern with the initial pattern operator whose name is 
provided. Furthermore,
    -    * the base type of the event sequence is set.
    -    *
    -    * @param name Name of the new pattern operator
    -    * @param <X> Base type of the event pattern
    -    * @return The first pattern operator of a pattern
    -    */
    -   public static <X> Pattern<X, X> begin(final String name) {
    -           return new Pattern<X, X>(name, null);
    -   }
    -
    -   /**
    -    * Specifies that this pattern can occur zero or more times(kleene 
star).
    -    * This means any number of events can be matched in this state.
    +    * Specifies that this pattern is optional for a final match of the 
pattern
    +    * sequence to happen.
         *
    -    * @return The same pattern with applied Kleene star operator
    -    *
    -    * @throws MalformedPatternException if quantifier already applied
    +    * @return The same pattern as optional.
    +    * @throws MalformedPatternException if the quantifier is not 
applicable to this pattern.
         */
    -   public Pattern<T, F> zeroOrMore() {
    -           return zeroOrMore(true);
    +   public Pattern<T, F> optional() {
    +           quantifier.optional();
    +           return this;
        }
     
        /**
    -    * Specifies that this pattern can occur zero or more times(kleene 
star).
    -    * This means any number of events can be matched in this state.
    -    *
    -    * If eagerness is enabled for a pattern A*B and sequence A1 A2 B will 
generate patterns:
    -    * B, A1 B and A1 A2 B. If disabled B, A1 B, A2 B and A1 A2 B.
    +    * Specifies that this pattern can occur {@code one or more} times.
    +    * This means at least one and at most infinite number of events can
    +    * be matched to this pattern.
         *
    -    * @param eager if true the pattern always consumes earlier events
    -    * @return The same pattern with applied Kleene star operator
    +    * <p>If this quantifier is enabled for a
    +    * pattern {@code A.oneOrMore().followedBy(B)} and a sequence of events
    +    * {@code A1 A2 B} appears, this will generate patterns:
    +    * {@code A1 B} and {@code A1 A2 B}. See also {@link 
#allowCombinations()}.
         *
    -    * @throws MalformedPatternException if quantifier already applied
    +    * @return The same pattern with a {@link Quantifier#ONE_OR_MORE()} 
quantifier applied.
    +    * @throws MalformedPatternException if the quantifier is not 
applicable to this pattern.
         */
    -   public Pattern<T, F> zeroOrMore(final boolean eager) {
    +   public Pattern<T, F> oneOrMore() {
                checkIfQuantifierApplied();
    -           if (eager) {
    -                   this.quantifier = Quantifier.ZERO_OR_MORE_EAGER;
    -           } else {
    -                   this.quantifier = Quantifier.ZERO_OR_MORE_COMBINATIONS;
    -           }
    +           this.quantifier = Quantifier.ONE_OR_MORE();
                return this;
        }
     
        /**
    -    * Specifies that this pattern can occur one or more times(kleene star).
    -    * This means at least one and at most infinite number of events can be 
matched in this state.
    +    * Specifies exact number of times that this pattern should be matched.
         *
    -    * @return The same pattern with applied Kleene plus operator
    +    * @param times number of times matching event must appear
    +    * @return The same pattern with number of times applied
         *
    -    * @throws MalformedPatternException if quantifier already applied
    +    * @throws MalformedPatternException if the quantifier is not 
applicable to this pattern.
         */
    -   public Pattern<T, F> oneOrMore() {
    -           return oneOrMore(true);
    +   public Pattern<T, F> times(int times) {
    +           checkIfQuantifierApplied();
    +           Preconditions.checkArgument(times > 0, "You should give a 
positive number greater than 0.");
    +           this.quantifier = Quantifier.TIMES();
    +           this.times = times;
    +           return this;
        }
     
        /**
    -    * Specifies that this pattern can occur one or more times(kleene star).
    -    * This means at least one and at most infinite number of events can be 
matched in this state.
    +    * Applicable only to {@link Quantifier#ONE_OR_MORE()} patterns, this 
option
    --- End diff --
    
    It is also applicable to `TIMES()`


> Make times() eager and enable allowing combinations.
> ----------------------------------------------------
>
>                 Key: FLINK-6356
>                 URL: https://issues.apache.org/jira/browse/FLINK-6356
>             Project: Flink
>          Issue Type: Bug
>          Components: CEP
>    Affects Versions: 1.3.0
>            Reporter: Kostas Kloudas
>            Assignee: Kostas Kloudas
>             Fix For: 1.3.0
>
>
> This is the PR that addresses it https://github.com/apache/flink/pull/3761



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

Reply via email to