我想将一个函数应用于flatMap生成的每个组DataSet.groupBy.试图调用flatMap我得到编译器错误:
error: value flatMap is not a member of org.apache.flink.api.scala.GroupedDataSet
Run Code Online (Sandbox Code Playgroud)
我的代码:
var mapped = env.fromCollection(Array[(Int, Int)]())
var groups = mapped.groupBy("myGroupField")
groups.flatMap( myFunction: (Int, Array[Int]) => Array[(Int, Array[(Int, Int)])] ) // error: GroupedDataSet has no member flatMap
Run Code Online (Sandbox Code Playgroud)
实际上,在flink-scala 0.9-SNAPSHOT的文档中没有map列出或类似的.是否有类似的方法可以使用?如何在节点上单独实现每个组的所需分布式映射?
我想将我的数据框(编辑:以 CPU 高效的方式)减少到具有 c3、c4 对唯一值的行,同时保留所有列。换句话说,我想转换我的数据框
> df <- data.frame(c1=seq(7), c2=seq(4, 10), c3=c("A", "B", "B", "C", "B", "A", "A"), c4=c(1, 2, 3, 3, 2, 2, 1))
c1 c2 c3 c4
1 1 4 A 1
2 2 5 B 2
3 3 6 B 3
4 4 7 C 3
5 5 8 B 2
6 6 9 A 2
7 7 10 A 1
Run Code Online (Sandbox Code Playgroud)
到数据框
c1 c2 c3 c4
1 1 4 A 1
2 2 5 B …Run Code Online (Sandbox Code Playgroud) 我希望拥有数据表的所有组的交集.所以对于给定的数据:
data.table(a=c(1,2,3, 2, 3,2), myGroup=c("x","x","x", "y", "z","z"))
Run Code Online (Sandbox Code Playgroud)
我希望得到结果:
2
Run Code Online (Sandbox Code Playgroud)
我知道
Reduce(intersect, list(c(1,2,3), c(2), c(3,2)))
Run Code Online (Sandbox Code Playgroud)
将给出我想要的结果,但我没有弄清楚如何生成data.table查询组的列表.