鉴于
val dstream = ssc.createStream(..)
我们如何从中获取分组/分组/拆分Dstream集,如下所示:
val (s1, s2, s3): (DStream[_],DStream[_],DStream[_]) =
dstream.map{ in match =>
case <cond1> => bucket1Value
case <cond2> => bucket2Value
case _ => bucket3Value
}.<some bucketing/grouping operation>
RE:可能重复这是完全不同的问题 - 另一个是 RDD 不是 DStream 的!
答案 0 :(得分:0)
回答我自己的问题:但如果有人(任何人?)有建议直接执行操作,那么很乐意接受。
所以这是一个解决方案 - 尽管不是很优雅。
val s1 = dstream.flatMap{ in match =>
case r if <cond1> => bucket1Value
case _ => None
}
val s2 = dstream.flatMap{ in match =>
case r if <cond2> => bucket1Value
case _ => None
}
val s3 = dstream.flatMap{ in match =>
case r if !<cond1> && !<cond2> => bucket3Value
case _ => None
}