I am using filter Api in basic wordcount program with Lambda expression but it is not working.
public class Count {
public static void main(String[] args) throws Exception {
final ExecutionEnvironment environment = ExecutionEnvironment.getExecutionEnvironment();
DataSet<String> text = environment.readTextFile(“/home/Malini/input11.txt”);
DataSet<Tuple2<String, Integer>> wordCounts = text
.filter(line -> line.contains(“Malini”))
.flatMap(new MySplitter())
.groupBy(0)
.sum(1);
wordCounts.print();
wordCounts.writeAsCsv(“/home/Malini/out000000334111.csv”);
environment.execute();
}
public static class MySplitter implements FlatMapFunction<String, Tuple2<String, Integer>> {
@Override
public void flatMap(String line, Collector<Tuple2<String, Integer>> out) {
for (String word : line.split(” “))
{
out.collect(new Tuple2<String, Integer>(word, 1));
}
}
}
}