我想从另一个 RDD 中减去一个 RDD。我查看了文档,发现subtract
可以做到这一点。实际上,当我测试时subtract
,最终的 RDD 保持不变,并且没有删除值!
有没有其他功能可以做到这一点?还是我使用subtract
不当?
这是我使用的代码:
val vertexRDD: org.apache.spark.rdd.RDD[(VertexId, Array[Int])]
val clusters = vertexRDD.takeSample(false, 3)
val clustersRDD: RDD[(VertexId, Array[Int])] = sc.parallelize(clusters)
val final = vertexRDD.subtract(clustersRDD)
final.collect().foreach(println(_))