标签:wordcount int spl str array set read one flink
package com.sjw.flink
import org.apache.flink.api.scala._
object WordCount {
def main(args: Array[String]): Unit = {
//创建批处理执行环境
val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment
//数据源 文件读取
val dataDS: DataSet[String] = env.readTextFile("src\\main\\resources\\words.txt")
//对DS处理
dataDS.flatMap(_.split(" ")).map((_,1)).groupBy(0).sum(1).print()
}
}
标签:wordcount int spl str array set read one flink
原文地址:https://www.cnblogs.com/whyuan/p/13276868.html