2016-06-26 36 views
2

我寫一個簡單的字數弗林克的工作,但我不斷收到此錯誤隱含值:無法找到證據參數

could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[String] 
[error] .flatMap{_.toLowerCase.split("\\W+") filter {_.nonEmpty}} 

我搜索網,但不能得到任何理解的答案。

這裏是我的代碼:

object Job { 
    def main(args: Array[String]) { 
    // set up the execution environment 
    val env = StreamExecutionEnvironment.getExecutionEnvironment 
    val dataStream = env.readTextFile("file:///home/plivo/code/flink/scala/flinkstream/test/") 

    val count = dataStream 
       .flatMap{_.toLowerCase.split("\\W+") filter {_.nonEmpty}} 
       .map{ (_,1) } 
       .groupBy(0) 
       .sum(1) 


    dataStream.print() 
    env.execute("Flink Scala API Skeleton") 
    } 
} 
+0

嘗試回答這個問題,它可以幫助你太:http://stackoverflow.com/questions/29540121/flink-scala-api-not-enough-arguments – richj

+0

我已經導入了所有必要的庫包括flink.api.scala._和flink.streaming.api.scala._ – sidd607

+0

問題是在flink(版本1.0.3)中的DataStream [(String,Int)]上沒有groupBy(...)方法)。有一個keyBy(Int)方法會產生一個KeyedStream [(String,Int),Tuple]。 – richj

回答

0

添加此:implicit val typeInfo = TypeInformation.of(classOf[(String)])def main(args: Array[String]) {...}第一行固定對我來說。

object Job { 
    def main(args: Array[String]) { 
    implicit val typeInfo = TypeInformation.of(classOf[(String)]) //Add this here 
    // set up the execution environment 
    val env = StreamExecutionEnvironment.getExecutionEnvironment 
    val dataStream = env.readTextFile("file:///home/plivo/code/flink/scala/flinkstream/test/") 

    val count = dataStream 
       .flatMap{_.toLowerCase.split("\\W+") filter {_.nonEmpty}} 
       .map{ (_,1) } 
       .groupBy(0) 
       .sum(1) 


    dataStream.print() 
    env.execute("Flink Scala API Skeleton") 
    } 
} 
相關問題