use of org.apache.hadoop.examples.pi.DistSum.Parameters in project hadoop by apache.
the class DistBbp method run.
/** {@inheritDoc} */
public int run(String[] args) throws Exception {
//parse arguments
if (args.length != DistSum.Parameters.COUNT + 1)
return Util.printUsage(args, getClass().getName() + " <b> " + Parameters.LIST + "\n <b> The number of bits to skip, i.e. compute the (b+1)th position." + Parameters.DESCRIPTION);
int i = 0;
final long b = Util.string2long(args[i++]);
final DistSum.Parameters parameters = DistSum.Parameters.parse(args, i);
if (b < 0)
throw new IllegalArgumentException("b = " + b + " < 0");
Util.printBitSkipped(b);
Util.out.println(parameters);
Util.out.println();
//initialize sums
final DistSum distsum = new DistSum();
distsum.setConf(getConf());
distsum.setParameters(parameters);
final boolean isVerbose = getConf().getBoolean(Parser.VERBOSE_PROPERTY, false);
final Map<Parameter, List<TaskResult>> existings = new Parser(isVerbose).parse(parameters.localDir.getPath(), null);
Parser.combine(existings);
for (List<TaskResult> tr : existings.values()) Collections.sort(tr);
Util.out.println();
final Map<Bellard.Parameter, Bellard.Sum> sums = Bellard.getSums(b, parameters.nJobs, existings);
Util.out.println();
//execute the computations
execute(distsum, sums);
//compute Pi from the sums
final double pi = Bellard.computePi(b, sums);
Util.printBitSkipped(b);
Util.out.println(Util.pi2string(pi, Bellard.bit2terms(b)));
return 0;
}
Aggregations