首页 > 解决方案 > How to convert RDD Structure

问题描述

How to convert

RDD[(String, (((A, B), C), D))] 

to

RDD[(String, (A, B, C, D))]

Do I need to use flatMapValues? I have no idea how to use it.

Can anybody help with this?

标签: apache-sparkrdd

解决方案


You can just use mapValues and select the values from tuple as

rdd.mapValues(x => (x._1._1._1, x._1._1._2, x._1._2, x._2))

推荐阅读