map vs mapValues in Spark
mapValues is only applicable for PairRDDs, meaning RDDs of the form RDD[(A, B)]. In that case, mapValues operates on the value only (the second part of the tuple), while map operates on the entire record (tuple of key and value). In other words, given f: B => C and rdd: RDD[(A, B)], these two are identical (almost – see comment at the bottom): The latter is simply shorter … Read more