[
https://issues.apache.org/jira/browse/FLINK-6165?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15946744#comment-15946744
]
ASF GitHub Bot commented on FLINK-6165:
---------------------------------------
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.
> 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)