Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E58AF200CDD for ; Mon, 7 Aug 2017 13:36:37 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id DE0F21651DE; Mon, 7 Aug 2017 11:36:37 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2EBAF1651DA for ; Mon, 7 Aug 2017 13:36:37 +0200 (CEST) Received: (qmail 17559 invoked by uid 500); 7 Aug 2017 11:36:36 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 17550 invoked by uid 99); 7 Aug 2017 11:36:36 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Aug 2017 11:36:36 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id CBCE81A1B85 for ; Mon, 7 Aug 2017 11:36:35 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.021 X-Spam-Level: X-Spam-Status: No, score=-4.021 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id jyYyaBY5rIWL for ; Mon, 7 Aug 2017 11:36:30 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id C8D325F3CD for ; Mon, 7 Aug 2017 11:36:29 +0000 (UTC) Received: (qmail 17473 invoked by uid 99); 7 Aug 2017 11:36:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Aug 2017 11:36:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 47EC9E10F8; Mon, 7 Aug 2017 11:36:27 +0000 (UTC) From: dawidwys To: issues@flink.incubator.apache.org Reply-To: issues@flink.incubator.apache.org References: In-Reply-To: Subject: [GitHub] flink issue #4296: [FLINK-7147] [cep] Support greedy quantifier in CEP Content-Type: text/plain Message-Id: <20170807113628.47EC9E10F8@git1-us-west.apache.org> Date: Mon, 7 Aug 2017 11:36:27 +0000 (UTC) archived-at: Mon, 07 Aug 2017 11:36:38 -0000 Github user dawidwys commented on the issue: https://github.com/apache/flink/pull/4296 There is also one more problem. When we have optional after `greedy` it does not work well. E.g. have a look at this test case: @Test public void testGreedyZeroOrMoreBeforeOptional2() { List> inputEvents = new ArrayList<>(); Event c = new Event(40, "c", 1.0); Event a1 = new Event(41, "a", 2.0); Event a2 = new Event(42, "a", 2.0); Event d = new Event(43, "d", 3.0); Event a3 = new Event(42, "a", 2.0); Event e = new Event(44, "e", 3.0); inputEvents.add(new StreamRecord<>(c, 1)); inputEvents.add(new StreamRecord<>(a1, 2)); inputEvents.add(new StreamRecord<>(a2, 3)); inputEvents.add(new StreamRecord<>(d, 4)); inputEvents.add(new StreamRecord<>(a3, 5)); inputEvents.add(new StreamRecord<>(e, 6)); // c a* d e Pattern pattern = Pattern.begin("start").where(new SimpleCondition() { private static final long serialVersionUID = 5726188262756267490L; @Override public boolean filter(Event value) throws Exception { return value.getName().equals("c"); } }).followedBy("middle1").where(new SimpleCondition() { private static final long serialVersionUID = 5726188262756267490L; @Override public boolean filter(Event value) throws Exception { return value.getName().equals("a"); } }).oneOrMore().optional().greedy().followedBy("middle2").where(new SimpleCondition() { private static final long serialVersionUID = 5726188262756267490L; @Override public boolean filter(Event value) throws Exception { return value.getName().equals("d"); } }).optional().followedBy("end").where(new SimpleCondition() { private static final long serialVersionUID = 5726188262756267490L; @Override public boolean filter(Event value) throws Exception { return value.getName().equals("e"); } }); NFA nfa = NFACompiler.compile(pattern, Event.createTypeSerializer(), false); final List> resultingPatterns = feedNFA(inputEvents, nfa); compareMaps(resultingPatterns, Lists.>newArrayList( Lists.newArrayList(c, a1, a2, a3, e), Lists.newArrayList(c, a1, a2, d, e) )); } Right know it also returns `c a1 a2 e`, which I think is not correct. I don't think there is an easy way to fix it right now. I would suggest restricting on the Pattern level that greedy must not be followed by an `Optional` patten. I would like to hear opinions on that, @kl0u. --- 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 infrastructure@apache.org or file a JIRA ticket with INFRA. ---