You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/04/26 07:07:04 UTC
[jira] [Commented] (FLINK-6356) Make times() eager and enable
allowing combinations.
[ https://issues.apache.org/jira/browse/FLINK-6356?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15984280#comment-15984280 ]
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_r113377152
--- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Quantifier.java ---
@@ -18,51 +18,83 @@
package org.apache.flink.cep.pattern;
import java.util.EnumSet;
+import java.util.Objects;
-public enum Quantifier {
- ONE,
- ZERO_OR_MORE_EAGER(QuantifierProperty.LOOPING, QuantifierProperty.EAGER),
- ZERO_OR_MORE_COMBINATIONS(QuantifierProperty.LOOPING),
- ZERO_OR_MORE_EAGER_STRICT(QuantifierProperty.EAGER, QuantifierProperty.STRICT, QuantifierProperty.LOOPING),
- ZERO_OR_MORE_COMBINATIONS_STRICT(QuantifierProperty.STRICT, QuantifierProperty.LOOPING),
- ONE_OR_MORE_EAGER(
- QuantifierProperty.LOOPING,
- QuantifierProperty.EAGER,
- QuantifierProperty.AT_LEAST_ONE),
- ONE_OR_MORE_EAGER_STRICT(
- QuantifierProperty.STRICT,
- QuantifierProperty.LOOPING,
- QuantifierProperty.EAGER,
- QuantifierProperty.AT_LEAST_ONE),
- ONE_OR_MORE_COMBINATIONS(QuantifierProperty.LOOPING, QuantifierProperty.AT_LEAST_ONE),
- ONE_OR_MORE_COMBINATIONS_STRICT(
- QuantifierProperty.STRICT,
- QuantifierProperty.LOOPING,
- QuantifierProperty.AT_LEAST_ONE),
- TIMES(QuantifierProperty.TIMES),
- TIMES_STRICT(QuantifierProperty.TIMES, QuantifierProperty.STRICT),
- OPTIONAL;
+public class Quantifier {
private final EnumSet<QuantifierProperty> properties;
- Quantifier(final QuantifierProperty first, final QuantifierProperty... rest) {
+ private Quantifier(final QuantifierProperty first, final QuantifierProperty... rest) {
this.properties = EnumSet.of(first, rest);
}
- Quantifier() {
- this.properties = EnumSet.noneOf(QuantifierProperty.class);
+ public static Quantifier ONE() {
+ return new Quantifier(QuantifierProperty.SINGLE);
+ }
+
+ public static Quantifier ONE_OR_MORE() {
+ return new Quantifier(QuantifierProperty.LOOPING, QuantifierProperty.EAGER);
+ }
+
+ public static Quantifier TIMES() {
+ return new Quantifier(QuantifierProperty.TIMES, QuantifierProperty.EAGER);
}
public boolean hasProperty(QuantifierProperty property) {
return properties.contains(property);
}
+ public void combinations() {
+ if (!hasProperty(Quantifier.QuantifierProperty.EAGER)) {
+ throw new MalformedPatternException("Combinations already allowed!");
+ }
+
+ if (hasProperty(Quantifier.QuantifierProperty.LOOPING) || hasProperty(Quantifier.QuantifierProperty.TIMES)) {
+ properties.remove(Quantifier.QuantifierProperty.EAGER);
+ } else {
+ throw new MalformedPatternException("Combinations not applicable to " + this + "!");
+ }
+ }
+
+ public void consecutive() {
+ if (hasProperty(Quantifier.QuantifierProperty.CONSECUTIVE)) {
--- End diff --
Same here for the `ONE` quantifier.
> 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)