我有一系列事件流,想将其平面映射到事件流中。
flatMap函数的语法有问题
val stream = DataStream[Seq[Event]]
stream.flatMap(???)
任何帮助将不胜感激
答案 0 :(得分:1)
I suggest you look at the examples that come with Flink, such as this wordcount application:
val counts: DataStream[(String, Int)] = text
// split up the lines in pairs (2-tuples) containing: (word,1)
.flatMap(_.toLowerCase.split("\\W+"))
.filter(_.nonEmpty)
.map((_, 1))
// group by the tuple field "0" and sum up tuple field "1"
.keyBy(0)
.sum(1)
The documentation also has helpful code snippets in scala (and java).