【问题标题】:Flink Scala API "not enough arguments"Flink Scala API“没有足够的参数”
【发布时间】:2015-04-09 13:38:44
【问题描述】:

我在使用 Apache Flink Scala API 时遇到问题

例如,即使我从官方文档中获取示例,scala 编译器也会给我带来大量编译错误。

代码:

object TestFlink {

  def main(args: Array[String]) {
    val env = ExecutionEnvironment.getExecutionEnvironment
    val text = env.fromElements(
      "Who's there?",
      "I think I hear them. Stand, ho! Who's there?")

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

    counts.print()

    env.execute("Scala WordCount Example")
  }
}

Scala IDE 为 val text = env.fromElements 行输出以下内容

Multiple markers at this line
  - not enough arguments for method fromElements: (implicit evidence$14: scala.reflect.ClassTag[String], implicit evidence$15: 
   org.apache.flink.api.common.typeinfo.TypeInformation[String])org.apache.flink.api.scala.DataSet[String]. Unspecified value parameter evidence$15.
  - could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[String]
  - could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[String]
  - not enough arguments for method fromElements: (implicit evidence$14: scala.reflect.ClassTag[String], implicit evidence$15: 
   org.apache.flink.api.common.typeinfo.TypeInformation[String])org.apache.flink.api.scala.DataSet[String]. Unspecified value parameter evidence$15.

这不仅仅是 fromElements 方法:即使我从文件中读取然后尝试做一些像 ds.map(r => r) 这样简单的事情,我也会得到非常相似的东西

Multiple markers at this line
    - not enough arguments for method map: (implicit evidence$4: org.apache.flink.api.common.typeinfo.TypeInformation[K], implicit 
     evidence$5: scala.reflect.ClassTag[K])org.apache.flink.api.scala.DataSet[K]. Unspecified value parameters evidence$4, evidence$5.
    - could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[K]
    - could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[K]
    - not enough arguments for method map: (implicit evidence$4: org.apache.flink.api.common.typeinfo.TypeInformation[K], implicit 
     evidence$5: scala.reflect.ClassTag[K])org.apache.flink.api.scala.DataSet[K]. Unspecified value parameters evidence$4, evidence$5.

我尝试了两个版本的 Flink:来自 Maven Central 的 0.8.1 和来自 github 存储库的最新版本。

我正在运行 Windows 7,scala 2.10.4,jdk 1.7.0_25,Scala IDE 版本是 Eclipse 4.3.0 之上的 3.0.3-20140327-1716-Typesafe

我做错了什么?

【问题讨论】:

    标签: scala-ide apache-flink


    【解决方案1】:

    您需要将以下导入添加到您的代码中:

    import org.apache.flink.api.scala._ 
    

    那么这个例子就起作用了。

    【讨论】:

    • 谢谢罗伯特。虽然它确实解决了所描述的问题,但我仍然对泛型参数有其他问题。请您看一下后续stackoverflow.com/questions/29542214
    • 我转发了问题... ;)
    猜你喜欢
    • 2020-06-04
    • 2017-03-29
    • 1970-01-01
    • 1970-01-01
    • 2020-06-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多