本文整理汇总了Java中org.apache.hadoop.examples.pi.DistSum.Parameters类的典型用法代码示例。如果您正苦于以下问题:Java Parameters类的具体用法?Java Parameters怎么用?Java Parameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Parameters类属于org.apache.hadoop.examples.pi.DistSum包,在下文中一共展示了Parameters类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.hadoop.examples.pi.DistSum.Parameters; //导入依赖的package包/类
/** {@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;
}