Java 8 lambdas for CEP patterns won't compile

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Java 8 lambdas for CEP patterns won't compile

David Koch
Hello,

I cannot get patterns expressed as lambdas like:

Pattern<Event, Event> pattern1 = Pattern.<Event> begin("start")
    .where(evt -> evt.key.length() > 0)
    .next("last").where(evt -> evt.key.length() > 0).within(Time.seconds(5));

to compile with Flink 1.3.0. My IDE doesn't handle it and building on command line with maven does not work either. The exception given by a maven build in command line is:

[ERROR] The method where(IterativeCondition<Event>) in the type Pattern<Event,Event> is not applicable for the arguments ((<no type> evt) -> {})
[ERROR] /Users/xxxx/xxx/cep-test/src/main/java/com/xxxx/xxxx/CEPTest.java:[83]
[ERROR] .where(evt -> evt.key.length() > 0)
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] The target type of this expression must be a functional interface

I used the standard pom.xml generated by the Flink quick start archetype. If I recall correctly this is something that used to work with Flink 1.2.0-SNAPSHOT back when I tested CEP for the first time.

Any idea why this could be the case or maybe my syntax is not correct? I include my maven information below.

Thank you,

David


Davids-MacBook-Pro-2:cep-test dkoch$ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_102, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"
Reply | Threaded
Open this post in threaded view
|

Re: Java 8 lambdas for CEP patterns won't compile

Ted Yu
Looking at docs/dev/libs/cep.md , there're 3 examples using lambda.
Here is one:

Pattern<Event, ?> pattern = Pattern.begin("start").where(evt -> evt.getId() == 42)

Your syntax should be supported.
I haven't found such example in test code, though.

FYI

On Sun, Jun 11, 2017 at 2:42 PM, David Koch <[hidden email]> wrote:
Hello,

I cannot get patterns expressed as lambdas like:

Pattern<Event, Event> pattern1 = Pattern.<Event> begin("start")
    .where(evt -> evt.key.length() > 0)
    .next("last").where(evt -> evt.key.length() > 0).within(Time.seconds(5));

to compile with Flink 1.3.0. My IDE doesn't handle it and building on command line with maven does not work either. The exception given by a maven build in command line is:

[ERROR] The method where(IterativeCondition<Event>) in the type Pattern<Event,Event> is not applicable for the arguments ((<no type> evt) -> {})
[ERROR] /Users/xxxx/xxx/cep-test/src/main/java/com/xxxx/xxxx/CEPTest.java:[83]
[ERROR] .where(evt -> evt.key.length() > 0)
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] The target type of this expression must be a functional interface

I used the standard pom.xml generated by the Flink quick start archetype. If I recall correctly this is something that used to work with Flink 1.2.0-SNAPSHOT back when I tested CEP for the first time.

Any idea why this could be the case or maybe my syntax is not correct? I include my maven information below.

Thank you,

David


Davids-MacBook-Pro-2:cep-test dkoch$ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_102, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"

Reply | Threaded
Open this post in threaded view
|

Re: Java 8 lambdas for CEP patterns won't compile

Kostas Kloudas
Hi David and Ted,

The documentation is outdated. I will update it today.
Java8 Lambdas are NOT supported by CEP in Flink 1.3.

Hopefully this will change soon. I will open a JIRA for this.

Cheers,
Kostas

On Jun 11, 2017, at 11:55 PM, Ted Yu <[hidden email]> wrote:

 

Reply | Threaded
Open this post in threaded view
|

Re: Java 8 lambdas for CEP patterns won't compile

Ted Yu
Do know which JIRA / discussion thread had the context for this decision ?

I did a quick search in JIRA but only found FLINK-3681.

Cheers

On Mon, Jun 12, 2017 at 1:48 AM, Kostas Kloudas <[hidden email]> wrote:
Hi David and Ted,

The documentation is outdated. I will update it today.
Java8 Lambdas are NOT supported by CEP in Flink 1.3.

Hopefully this will change soon. I will open a JIRA for this.

Cheers,
Kostas

On Jun 11, 2017, at 11:55 PM, Ted Yu <[hidden email]> wrote:

 


Reply | Threaded
Open this post in threaded view
|

Re: Java 8 lambdas for CEP patterns won't compile

Kostas Kloudas
Unfortunately, there was no discussion as this regression came as an 
artifact of the addition of the IterativeConditions, but it will be fixed.

This is the JIRA to track it:
https://issues.apache.org/jira/browse/FLINK-6897

Kostas

On Jun 12, 2017, at 11:51 AM, Ted Yu <[hidden email]> wrote:

Do know which JIRA / discussion thread had the context for this decision ?

I did a quick search in JIRA but only found FLINK-3681.

Cheers

On Mon, Jun 12, 2017 at 1:48 AM, Kostas Kloudas <[hidden email]> wrote:
Hi David and Ted,

The documentation is outdated. I will update it today.
Java8 Lambdas are NOT supported by CEP in Flink 1.3.

Hopefully this will change soon. I will open a JIRA for this.

Cheers,
Kostas

On Jun 11, 2017, at 11:55 PM, Ted Yu <[hidden email]> wrote:

 



Reply | Threaded
Open this post in threaded view
|

Re: Java 8 lambdas for CEP patterns won't compile

Ted Yu
Can you add link to this thread in the JIRA ?

Cheers

On Mon, Jun 12, 2017 at 3:15 AM, Kostas Kloudas <[hidden email]> wrote:
Unfortunately, there was no discussion as this regression came as an 
artifact of the addition of the IterativeConditions, but it will be fixed.

This is the JIRA to track it:
https://issues.apache.org/jira/browse/FLINK-6897

Kostas

On Jun 12, 2017, at 11:51 AM, Ted Yu <[hidden email]> wrote:

Do know which JIRA / discussion thread had the context for this decision ?

I did a quick search in JIRA but only found FLINK-3681.

Cheers

On Mon, Jun 12, 2017 at 1:48 AM, Kostas Kloudas <[hidden email]> wrote:
Hi David and Ted,

The documentation is outdated. I will update it today.
Java8 Lambdas are NOT supported by CEP in Flink 1.3.

Hopefully this will change soon. I will open a JIRA for this.

Cheers,
Kostas

On Jun 11, 2017, at 11:55 PM, Ted Yu <[hidden email]> wrote:

 




Reply | Threaded
Open this post in threaded view
|

Re: Java 8 lambdas for CEP patterns won't compile

Kostas Kloudas
Done.

On Jun 12, 2017, at 12:24 PM, Ted Yu <[hidden email]> wrote:

Can you add link to this thread in the JIRA ?

Cheers

On Mon, Jun 12, 2017 at 3:15 AM, Kostas Kloudas <[hidden email]> wrote:
Unfortunately, there was no discussion as this regression came as an 
artifact of the addition of the IterativeConditions, but it will be fixed.

This is the JIRA to track it:
https://issues.apache.org/jira/browse/FLINK-6897

Kostas

On Jun 12, 2017, at 11:51 AM, Ted Yu <[hidden email]> wrote:

Do know which JIRA / discussion thread had the context for this decision ?

I did a quick search in JIRA but only found FLINK-3681.

Cheers

On Mon, Jun 12, 2017 at 1:48 AM, Kostas Kloudas <[hidden email]> wrote:
Hi David and Ted,

The documentation is outdated. I will update it today.
Java8 Lambdas are NOT supported by CEP in Flink 1.3.

Hopefully this will change soon. I will open a JIRA for this.

Cheers,
Kostas

On Jun 11, 2017, at 11:55 PM, Ted Yu <[hidden email]> wrote:

 





Reply | Threaded
Open this post in threaded view
|

Re: Java 8 lambdas for CEP patterns won't compile

David Koch
Thank you! Hoping to see Lambda support added back in soon as well.

Regards,

David

On Mon, Jun 12, 2017 at 1:57 PM, Kostas Kloudas <[hidden email]> wrote:
Done.

On Jun 12, 2017, at 12:24 PM, Ted Yu <[hidden email]> wrote:

Can you add link to this thread in the JIRA ?

Cheers

On Mon, Jun 12, 2017 at 3:15 AM, Kostas Kloudas <[hidden email]> wrote:
Unfortunately, there was no discussion as this regression came as an 
artifact of the addition of the IterativeConditions, but it will be fixed.

This is the JIRA to track it:
https://issues.apache.org/jira/browse/FLINK-6897

Kostas

On Jun 12, 2017, at 11:51 AM, Ted Yu <[hidden email]> wrote:

Do know which JIRA / discussion thread had the context for this decision ?

I did a quick search in JIRA but only found FLINK-3681.

Cheers

On Mon, Jun 12, 2017 at 1:48 AM, Kostas Kloudas <[hidden email]> wrote:
Hi David and Ted,

The documentation is outdated. I will update it today.
Java8 Lambdas are NOT supported by CEP in Flink 1.3.

Hopefully this will change soon. I will open a JIRA for this.

Cheers,
Kostas

On Jun 11, 2017, at 11:55 PM, Ted Yu <[hidden email]> wrote: