如何成为二级朋友

时间:2016-01-25 10:43:50

标签: scala apache-spark rdd

我有一个RDD,它的元素是这样的:(k,<iterable list>),(imagine key is a vertex and values are it's neighbors)。我想找到二级朋友(朋友的朋友)。所以我应该有两个嵌套循环来创建这个键值对:((I,J),2) 这是源代码:

(key i, ValueIterator friesndlist)
foreach k member of friesndlist do 
  foreach m member of friesndlist  do 
     emit ((k,m),2)

我有这段代码:

val lines = sc.textFile("followers.txt").map(s => {
  val substrings = s.split(" ")
  (substrings(0), substrings(1))
})
  val aggrigateNeighbors = lines.groupByKey()

我该怎么做?

0 个答案:

没有答案