Developement/Cloud
GridGain을 이용한 MapReduce
highheat
2011. 11. 23. 16:36
import org.gridgain.grid.*;
import org.gridgain.grid.typedef.*;
import static org.gridgain.grid.GridClosureCallMode.*;
public class JavaMapReduce {
public static void main(String[] args) throws GridException{
G.start();
X.println("Count is : "+mapReduceCount("Java GridGain MapReduce"));
G.stop(true);
}
public static int mapReduceCount(String msg) throws GridException {
return G.grid().reduce(
SPREAD,
F.yield(
msg.split(" "),
new C1<String, Integer>(){
@Override
public Integer apply(String s) {
X.println("Calculating for : "+s);
return s.length();
}
}
),
F.sumIntReducer()
);
}
}