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/08/01 07:37:00 UTC
[jira] [Commented] (FLINK-7147) Support greedy quantifier in CEP
[ https://issues.apache.org/jira/browse/FLINK-7147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16108520#comment-16108520 ]
ASF GitHub Bot commented on FLINK-7147:
---------------------------------------
Github user dawidwys commented on a diff in the pull request:
https://github.com/apache/flink/pull/4296#discussion_r130537682
--- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java ---
@@ -657,25 +663,34 @@ private boolean isPatternOptional(Pattern<T, ?> pattern) {
true);
IterativeCondition<T> proceedCondition = getTrueFunction();
- if (currentPattern.getQuantifier().isGreedy()) {
- proceedCondition = getGreedyCondition(proceedCondition, Lists.newArrayList(takeCondition));
+ if (currentPattern.getQuantifier().hasProperty(Quantifier.QuantifierProperty.GREEDY)) {
+ proceedCondition = getGreedyCondition(
+ proceedCondition,
+ takeCondition,
+ ignoreCondition,
+ followingTakeCondition);;
}
final State<T> loopingState = createState(currentPattern.getName(), State.StateType.Normal,
- currentPattern.getQuantifier().isGreedy());
+ currentPattern.getQuantifier().hasProperty(Quantifier.QuantifierProperty.GREEDY));
loopingState.addProceed(sinkState, proceedCondition);
loopingState.addTake(takeCondition);
addStopStateToLooping(loopingState);
if (ignoreCondition != null) {
final State<T> ignoreState = createState(currentPattern.getName(), State.StateType.Normal,
- currentPattern.getQuantifier().isGreedy());
+ currentPattern.getQuantifier().hasProperty(Quantifier.QuantifierProperty.GREEDY));
ignoreState.addTake(loopingState, takeCondition);
ignoreState.addIgnore(ignoreCondition);
loopingState.addIgnore(ignoreState, ignoreCondition);
+ if (currentPattern.getQuantifier().hasProperty(Quantifier.QuantifierProperty.GREEDY)) {
--- End diff --
I think the problem you mentioned with `GreedyITCase.testGreedyZeroOrMoreBeforeOptional2` is due to that proceed. The whole reason behind the additional ignoreState was for it not to have the `PROCEED` transition as it creates additional computationStates with the `sinkState`. I think for the greedy to work we need to put customized ignoreCondition into the `sinkState` of a greedy Pattern. What do you think?
> Support greedy quantifier in CEP
> --------------------------------
>
> Key: FLINK-7147
> URL: https://issues.apache.org/jira/browse/FLINK-7147
> Project: Flink
> Issue Type: Sub-task
> Components: CEP, Table API & SQL
> Reporter: Dian Fu
> Assignee: Dian Fu
>
> Greedy quantifier will try to match the token as many times as possible. For example, for pattern {{a b* c}} (skip till next is used) and inputs {{a b1 b2 c}}, if the quantifier for {{b}} is greedy, it will only output {{a b1 b2 c}}.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)