scala-ide - Flink Scala API "not enough arguments"

标签 scala-ide apache-flink

我在使用 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 版本为 3.0.3-20140327-1716-Typesafe,基于 Eclipse 4.3.0

我做错了什么?

最佳答案

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

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

然后该示例就可以运行。

关于scala-ide - Flink Scala API "not enough arguments",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29540121/

相关文章:

Eclipse 无法识别 Scala 源目录

java - 如何以正确的方式创建 Scala 项目?

apache-flink - 如何配置 Flink 使用 Hdfs 进行后端状态和检查点

batch-processing - Apache Flink - DataSet API - 如何将 n 个结果分组在一起

scala - 我应该为命令行和 Eclipse IDE 单独安装 Scala 吗?

debugging - Eclipse Scala 解释器 (REPL) - 正确使用和调试

eclipse - Eclipse 中的编译器无法识别 Scala 源文件

machine-learning - Apache Flink 数据流上的随机异常值选择

java - 在 Dataset<Row> 对象中转换 Flink CEP 表时出错

java - 即使在 apache flink 中实现 AppendTableStream 接口(interface)后仍出现以下错误