簡體   English   中英

TypeInformation未定義

[英]TypeInformation not defined

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)
              ^
              ^

使用Flink的Scala DataSet API時,必須在代碼中添加以下導入: import org.apache.flink.api.scala._

使用Flink的Scala DataStream API時,您必須導入import org.apache.flink.streaming.api.scala._

原因是包對象包含一個生成缺少的TypeInformation實例的函數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM