You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Sonex <al...@gmail.com> on 2017/06/19 07:35:19 UTC
FlinkCEP 1.3 scala, cannot apply select function
Hello I have created a simple pattern with FlinkCEP 1.3 as well as a simple
pattern select function. My simple function is as follows:
def myFunction(pattern: Map[String,Iterable[MyEventType]]): MyEventType = {
val startEvent = pattern.get("first").get.head
val endEvent = pattern.get("second").get.head
// dummy functionality for illustrating purposes
endEvent
}
When I apply the function above to a pattern in the following way:
CEP.pattern(myKeyedStream,myDummyPattern).select(myFunction(_)) it gives the
following error:
Cannot resolve reference myFunction with such signature.
Type mismatch, expected:
scala.Predef.Map[scala.Predef.String,scala.Iterable[MyEventType]], actual:
scala.collection.Map[scala.Predef.String,scala.Iterable[MyEventType]]
What is the reason of this behavior?
--
View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/FlinkCEP-1-3-scala-cannot-apply-select-function-tp13824.html
Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.
Re: FlinkCEP 1.3 scala, cannot apply select function
Posted by Sonex <al...@gmail.com>.
Thank you for your quick response. That worked and compiled but another error
came up. On runtime it gives the following error:
java.lang.ClassCastException: MyEventType cannot be cast to
scala.collection.IterableLike
The error is at line
val startEvent = pattern.get("first").get.head
of myFunction.
--
View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/FlinkCEP-1-3-scala-cannot-apply-select-function-tp13824p13828.html
Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.
Re: FlinkCEP 1.3 scala, cannot apply select function
Posted by Dawid Wysakowicz <wy...@gmail.com>.
Hi,
Because of some optimizations between java <-> scala collections
conversions, the type of Map used for select method is scala.collection.Map
instead of Predef.Map imported by default.
Try importing:
import scala.collection.Map
or use fully qualified name in function definition:
def myFunction(pattern: scala.collection.Map[String,Iterable[MyEventType]]):
> MyEventType = {
> val startEvent = pattern.get("first").get.head
> val endEvent = pattern.get("second").get.head
> // dummy functionality for illustrating purposes
> endEvent
> }
Z pozdrowieniami! / Cheers!
Dawid Wysakowicz
*Data/Software Engineer*
Skype: dawid_wys | Twitter: @OneMoreCoder
<http://getindata.com/>
2017-06-19 9:35 GMT+02:00 Sonex <al...@gmail.com>:
> Hello I have created a simple pattern with FlinkCEP 1.3 as well as a simple
> pattern select function. My simple function is as follows:
>
> def myFunction(pattern: Map[String,Iterable[MyEventType]]): MyEventType =
> {
> val startEvent = pattern.get("first").get.head
> val endEvent = pattern.get("second").get.head
> // dummy functionality for illustrating purposes
> endEvent
> }
>
> When I apply the function above to a pattern in the following way:
>
> CEP.pattern(myKeyedStream,myDummyPattern).select(myFunction(_)) it gives
> the
> following error:
>
> Cannot resolve reference myFunction with such signature.
>
> Type mismatch, expected:
> scala.Predef.Map[scala.Predef.String,scala.Iterable[MyEventType]], actual:
> scala.collection.Map[scala.Predef.String,scala.Iterable[MyEventType]]
>
> What is the reason of this behavior?
>
>
>
>
>
> --
> View this message in context: http://apache-flink-user-
> mailing-list-archive.2336050.n4.nabble.com/FlinkCEP-1-3-
> scala-cannot-apply-select-function-tp13824.html
> Sent from the Apache Flink User Mailing List archive. mailing list archive
> at Nabble.com.
>