flatMap

flatMap takes one record as input and gives an output of zero, one, or more than one record:

In Java:

inputStream.flatMap(new FlatMapFunction<String, String>() {
@Override
public void flatMap(String value, Collector<String> out)
throws Exception {
for(String word: value.split(" ")){
out.collect(word);
}
});

In Scala:

inputStream.flatMap { str => str.split(" ") }
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset