In the below code I am trying read a text file as an rdd and I am calling the map method because I want to transpose each line and append it to the String Builder object. But I want to return the String Builder object after I have finished with each line . But here I am returning it at each line . So when I do a exposuresRdd.saveAsTextFile().
I am getting the output as (repeats) a b
a b c
a b c d
where as I want it to be a b c d e f
It should not repeat
JavaRDD<String> exposuresRdd = ctx.textFile(fname);
JavaRDD<String> transformedrdd= exposuresRdd.flatMap(new Function<String, String>() {
@Override
public String call(String line) throws Exception {
sb.append(Something);
return sb.toString();
});
}