From issues-return-161189-archive-asf-public=cust-asf.ponee.io@flink.apache.org Sun Apr 1 15:11:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id B4BBA180634 for ; Sun, 1 Apr 2018 15:11:04 +0200 (CEST) Received: (qmail 47690 invoked by uid 500); 1 Apr 2018 13:11:03 -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 47676 invoked by uid 99); 1 Apr 2018 13:11:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Apr 2018 13:11:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 34BABC00CF for ; Sun, 1 Apr 2018 13:11:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.311 X-Spam-Level: X-Spam-Status: No, score=-110.311 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 1S8ArPrkMavx for ; Sun, 1 Apr 2018 13:11:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id E54775F1B4 for ; Sun, 1 Apr 2018 13:11:00 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 7526DE01A8 for ; Sun, 1 Apr 2018 13:11:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 1E39F25601 for ; Sun, 1 Apr 2018 13:11:00 +0000 (UTC) Date: Sun, 1 Apr 2018 13:11:00 +0000 (UTC) From: "aitozi (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Assigned] (FLINK-8914) CEP's greedy() modifier doesn't work MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FLINK-8914?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:all-tabpanel ] aitozi reassigned FLINK-8914: ----------------------------- Assignee: aitozi > CEP's greedy() modifier doesn't work > ------------------------------------ > > Key: FLINK-8914 > URL: https://issues.apache.org/jira/browse/FLINK-8914 > Project: Flink > Issue Type: Bug > Components: CEP > Affects Versions: 1.4.0, 1.4.1 > Reporter: David Anderson > Assignee: aitozi > Priority: Major > > When applied to the first or last component of a CEP Pattern, greedy() do= esn't work correctly. Here's an example: > {code:java} > package com.dataartisans.flinktraining.exercises.datastream_java.cep; > import org.apache.flink.cep.CEP; > import org.apache.flink.cep.PatternSelectFunction; > import org.apache.flink.cep.PatternStream; > import org.apache.flink.cep.pattern.Pattern; > import org.apache.flink.cep.pattern.conditions.SimpleCondition; > import org.apache.flink.streaming.api.datastream.DataStream; > import org.apache.flink.streaming.api.environment.StreamExecutionEnvironm= ent; > import java.util.List; > import java.util.Map; > public class RunLength { > public static void main(String[] args) throws Exception { > StreamExecutionEnvironment env =3D StreamExecutionEnvironment.getExec= utionEnvironment(); > env.setParallelism(1); > DataStream input =3D env.fromElements(1, 1, 1, 1, 1, 0, 1, 1= , 1, 0); > Pattern onesThenZero =3D Pattern.begin("ones") > .where(new SimpleCondition() { > @Override > public boolean filter(Integer value) throws Exception { > return value =3D=3D 1; > } > }) > .oneOrMore() > .greedy() > .consecutive() > .next("zero") > .where(new SimpleCondition() { > @Override > public boolean filter(Integer value) throws Exception { > return value =3D=3D 0; > } > }); > PatternStream patternStream =3D CEP.pattern(input, onesThe= nZero); > // Expected: 5 3 > // Actual: 5 4 3 2 1 3 2 1 > patternStream.select(new LengthOfRun()).print(); > env.execute(); > } > public static class LengthOfRun implements PatternSelectFunction { > public Integer select(Map> pattern) { > return pattern.get("ones").size(); > } > } > } > {code} > The only=C2=A0workaround for now seems to be=C2=A0to rewrite the pattern = so that greedy() isn't needed =E2=80=93 i.e. by bracketing the greedy secti= on with a prefix and suffix that both have to be matched. -- This message was sent by Atlassian JIRA (v7.6.3#76005)