Avoid List of Iterators
newRDD = textRDD.map(line => line.split(","))val inputData = sc.parallelize (Array ("foo,bar,baz", "larry,moe,curly", "one,two,three") ).cache ()
val mapped = inputData.map (line => line.split (",") )
val flatMapped = inputData.flatMap (line => line.split (",") )
val mappedResults = mapped.collect ()
val flatMappedResults = flatMapped.collect ();
println ("Mapped results of split")
println (mappedResults.mkString (" : ") )
println ("FlatMapped results of split")
println (flatMappedResults.mkString (" : ") )Mapped results of split
[Ljava.lang.String;@45e22def : [Ljava.lang.String;@6ae3fb94 : [Ljava.lang.String;@4417af13
FlatMapped results of split
foo : bar : baz : larry : moe : curly : one : two : threePreviousPicking the Right OperatorsNextAvoid groupByKey when performing a group of multiple items by key
Last updated