Would Spark preserve key order with this sortByKey/map/collect sequence?
问题 Let us say, we have this. val sx = sc.parallelize(Array((0, 39), (4, 47), (3, 51), (1, 98), (2, 61))) And we later call this. val sy = sx.sortByKey(true) Which would make sy = RDD[(0, 39), (1, 98), (2, 61), (3, 51), (4, 47)] And then we do collected = sy.map(x => (x._2 / 10, x._2)).collect Would we always get the following. I mean, would the original key order be preserved, despite changing the key values? collected = [(3, 39), (9, 98), (6, 61), (5, 51), (4, 47)] 回答1: Applying the map()