-2

我有两个 RDDrdd1rdd2类型RDD[String]

我在 scala spark 的两个 RDD 上执行了笛卡尔积

val cartesianproduct = rdd1.cartesian(rdd2)

当我执行以下代码时,出现错误。

val splitup = cartesianproduct.map(line => line.split(","))

以下是我得到的错误:

错误:值拆分不是(字符串,字符串)的成员

4

1 回答 1

1

Cartesian join 返回RDDofTuple2[String, String]所以你必须在Tuple2[String, String]not on 上执行 map 操作String,这里是如何在 map 函数中处理 Tuple 的例子

val cartesianproduct = rdd1.cartesian(rdd2)
val splitup = cartesianproduct.map{ case (line1, line2) => line1.split(",") ++ line2.split(",")}
于 2018-06-17T11:22:28.607 回答