2016-03-01 74 views
1
object EventConsumer { 

    def main(args: Array[String]): Unit = { 
    val env = ExecutionEnvironment.getExecutionEnvironment 

    val data1 = env.readTextFile("file:////some_events.txt"); 
    // Define the data source 
    data1 .map (new myMapFunction) 
    } 

    class myMapFunction extends MapFunction[String,Unit] 
    { 
    override def map(in: String): Unit = { 
     println(in) 
    } 
    } 
} 

真的长期困在这个编译错误,请帮忙。类型信息没有定义

Error:(27, 15) could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[String] 
     flatMap { _.split("\n")}.filter(_.nonEmpty).map (new myMapFunction) 

Error:(24, 15) not enough arguments for method map: (implicit evidence$2: org.apache.flink.api.common.typeinfo.TypeInformation[Unit], implicit evidence$3: scala.reflect.ClassTag[Unit])org.apache.flink.api.scala.DataSet[Unit]. 
Unspecified value parameters evidence$2, evidence$3. 
    data1.map (new myMapFunction) 
      ^
      ^

回答

1

当使用弗林克的斯卡拉DataSet的API,需要以下导入添加到您的代码:import org.apache.flink.api.scala._

当使用Flink的Scala DataStream API时,您必须导入import org.apache.flink.streaming.api.scala._

原因是包对象包含一个函数,该函数会生成缺少的TypeInformation实例。

+0

谢谢你的工作。 – balaji

相关问题