Ale*_*rev 10 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")
}
}
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
这不仅仅是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.
Run Code Online (Sandbox Code Playgroud)
我尝试了两个版本的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之上
我究竟做错了什么?
Rob*_*ger 21
您需要在代码中添加以下导入:
import org.apache.flink.api.scala._
Run Code Online (Sandbox Code Playgroud)
然后该示例有效.
| 归档时间: |
|
| 查看次数: |
2766 次 |
| 最近记录: |