I have used this example which is present in most of the sites..
int letterCnt = G.grid().reduce(
GridClosureCallMode.SPREAD,
F.yield("Counting Letters In This Phrase".split(" "),
new C1<String, Integer>() {
@Override public Integer apply(String word) {
return word.length();
}
}
),
F.sumIntReducer()
);
The First argument denotes the equal distribution of work load( i assume its more like round robin basis) The Second argument has the code that will be executed in all the discovered nodes The Third which receives all result data from apply() executed in different nodes and processes accordingly.
I would like to know whether it is possible to substitute the third argument F.sumIntReducer() with a function of our own. If yes, I would like to see an example. Let's say creating the same function that has the same functionality of F.sumIntReducer() (i.e. sum's up all the length found by different nodes).
Yes, you can define your own custom reducer. The example is here.