You can convert the dataframe to RDD first before doing the flatMap
and map
operations:
var data = names.rdd
.flatMap(name => name.getString(0).toCharArray)
.map(rec => (rec, 1))
.reduce((x, y) => ('S', x._2 + y._2))
which will return 6, because you're just counting the number of chars in the first column of the dataframe. Not sure if this is your desired output.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…