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(" ") }