type mismatch: required ?, found String

102 views
Skip to first unread message

sca...@tutanota.com

unread,
May 24, 2016, 11:05:46 AM5/24/16
to scala-user
I am playing with Apache beam's MinimalWordCount, but compiler complains 

[error]  found   : org.apache.beam.sdk.transforms.SimpleFunction[org.apache.beam.sdk.values.KV[String,Long],String]
[error]  required: org.apache.beam.sdk.transforms.SimpleFunction[org.apache.beam.sdk.values.KV[String,Long],?]
[error]             MapElements.via(new SimpleFunction[KV[String, Long], String]() {

I am not sure what goes wrong because the code have return type configured to String as type parameter, and the code is exactly the same as MinimalWordCount, except that is written in scala version. 

      apply("FormatResults",
            MapElements.via(new SimpleFunction[KV[String, Long], String]() {
              override def apply(input: KV[String, Long]): String =
                input.getKey.toString + ": " + input.getValue.toString
            })
      )
 
Maybe I am missing some concepts in type system? How can I fix this error?

I use scala 2.11.x, sbt 0.13.11, java 1.8.0_91. 

Thanks


sca...@tutanota.com

unread,
May 25, 2016, 4:25:23 AM5/25/16
to scala-user
The problem is solved by changing one of the scala Long type to java.lang.Long. Thanks.
Reply all
Reply to author
Forward
0 new messages