Replace mapValues with one single map to avoid serialization in frameworks like Spark.