在scala中迭代spark cogroup()pairrdd输出

时间:2016-10-07 14:07:45

标签: scala apache-spark

我在Spark中创建了2对RDD&#39

var cogrouped = pairrdd.cogroup(pairrdd2)

我应用了cogroup函数

cogrouped: org.apache.spark.rdd.RDD[(Int, (Iterable[Int], Iterable[Int]))] = MapPartitionsRDD[801] at cogroup at <console>:60

cogroupedrdd的对象类型如下所示。

def iterateThis((x: Int,(x1:Iterable[Int],x2:Iterable[Int])))={
  println(x1.mkString(","))
}

我正在尝试创建一个迭代这些值的函数

<console>:21: error: identifier expected but '(' found.
       def iterateThis((x: Int,(x1:Iterable[Int],x2:Iterable[Int])))={
                   ^

但是我得到了错误。

Dim field(7) As Object

For i As Integer = 0 To UBound(field)
    field(i) = Nothing
Next

1 个答案:

答案 0 :(得分:1)

您的参数类型为(Int, (Iterable[Int], Iterable[Int]))

def iterateThis(arg: (Int, (Iterable[Int], Iterable[Int]))) = {
  val (_, (x1, _)) = arg
  println(x1.mkString(","))
}