hmm, I finally found that the following syntax works better :

scala> val mappingFunction = (key: String, value: Option[Int], state: 
State[Int]) => {
     | Option(key)
     | }
mappingFunction: (String, Option[Int], org.apache.spark.streaming.State[Int]) 
=> Option[String] = <function3>

scala> val spec = StateSpec.function(mappingFunction)
spec: org.apache.spark.streaming.StateSpec[String,Int,Int,Option[String]] = 
StateSpecImpl(<function4>)

This code comes from one of the spark examples. If anyone can explain me the 
difference between the two.

Regards 
> On Mar 27, 2016, at 23:57, Cyril Scetbon <cyril.scet...@free.fr> wrote:
> 
> Hi,
> 
> I'm testing a sample code and I get this error. Here is the sample code I use 
> :
> 
> scala> import org.apache.spark.streaming._
> import org.apache.spark.streaming._
> 
> scala> def mappingFunction(key: String, value: Option[Int], state: 
> State[Int]): Option[String] = {
>     |    Option(key)
>     | }
> mappingFunction: (key: String, value: Option[Int], state: 
> org.apache.spark.streaming.State[Int])Option[String]
> 
> scala> val spec = StateSpec.function(mappingFunction)
> <console>:41: error: missing arguments for method mappingFunction;
> follow this method with `_' if you want to treat it as a partially applied 
> function
>         val spec = StateSpec.function(mappingFunction)
>                                       ^
> I followed the current documentation 
> https://spark.apache.org/docs/1.6.1/api/java/org/apache/spark/streaming/StateSpec.html
> 
> Any idea ?
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@spark.apache.org
> For additional commands, e-mail: user-h...@spark.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@spark.apache.org
For additional commands, e-mail: user-h...@spark.apache.org

Reply via email to