本文整理汇总了Java中org.apache.hadoop.examples.pi.math.Bellard.Parameter类的典型用法代码示例。如果您正苦于以下问题:Java Parameter类的具体用法?Java Parameter怎么用?Java Parameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Parameter类属于org.apache.hadoop.examples.pi.math.Bellard包,在下文中一共展示了Parameter类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: combine
import org.apache.hadoop.examples.pi.math.Bellard.Parameter; //导入依赖的package包/类
/** Combine results */
static <T extends Combinable<T>> Map<Parameter, T> combine(Map<Parameter, List<T>> m) {
final Map<Parameter, T> combined = new TreeMap<Parameter, T>();
for(Parameter p : Parameter.values()) {
//note: results would never be null due to the design of Util.combine
final List<T> results = Util.combine(m.get(p));
Util.out.format("%-6s => ", p);
if (results.size() != 1)
Util.out.println(results.toString().replace(", ", ",\n "));
else {
final T r = results.get(0);
combined.put(p, r);
Util.out.println(r);
}
}
return combined;
}
示例2: main
import org.apache.hadoop.examples.pi.math.Bellard.Parameter; //导入依赖的package包/类
/** main */
public static void main(String[] args) throws IOException {
if (args.length < 2 || args.length > 3)
Util.printUsage(args, Parser.class.getName()
+ " <b> <inputpath> [<outputdir>]");
int i = 0;
final long b = Util.string2long(args[i++]);
final String inputpath = args[i++];
final String outputdir = args.length >= 3? args[i++]: null;
//read input
final Map<Parameter, List<TaskResult>> parsed = new Parser(true).parse(inputpath, outputdir);
final Map<Parameter, TaskResult> combined = combine(parsed);
long duration = 0;
for(TaskResult r : combined.values())
duration += r.getDuration();
//print pi
final double pi = Bellard.computePi(b, combined);
Util.printBitSkipped(b);
Util.out.println(Util.pi2string(pi, Bellard.bit2terms(b)));
Util.out.println("cpu time = " + Util.millis2String(duration));
}
示例3: execute
import org.apache.hadoop.examples.pi.math.Bellard.Parameter; //导入依赖的package包/类
/** Execute DistSum computations */
private void execute(DistSum distsum,
final Map<Bellard.Parameter, Bellard.Sum> sums) throws Exception {
final List<Computation> computations = new ArrayList<Computation>();
int i = 0;
for(Bellard.Parameter p : Bellard.Parameter.values())
for(Summation s : sums.get(p))
if (s.getValue() == null)
computations.add(distsum.new Computation(i++, p.toString(), s));
if (computations.isEmpty())
Util.out.println("No computation");
else {
timer.tick("execute " + computations.size() + " computation(s)");
Util.execute(distsum.getParameters().nThreads, computations);
timer.tick("done");
}
}
示例4: combine
import org.apache.hadoop.examples.pi.math.Bellard.Parameter; //导入依赖的package包/类
/** Combine results */
static <T extends Combinable<T>> Map<Parameter, T> combine(Map<Parameter, List<T>> m) {
final Map<Parameter, T> combined = new TreeMap<Parameter, T>();
for(Parameter p : Parameter.values()) {
final List<T> results = Util.combine(m.get(p));
Util.out.format("%-6s => ", p);
if (results == null)
Util.out.println("null");
else if (results.size() != 1)
Util.out.println(results.toString().replace(", ", ",\n "));
else {
final T r = results.get(0);
combined.put(p, r);
Util.out.println(r);
}
}
return combined;
}
示例5: parseLine
import org.apache.hadoop.examples.pi.math.Bellard.Parameter; //导入依赖的package包/类
/** Parse a line */
private static void parseLine(final String line, Map<Parameter, List<TaskResult>> m) {
// LOG.info("line = " + line);
final Map.Entry<String, TaskResult> e = DistSum.string2TaskResult(line);
if (e != null) {
final List<TaskResult> sums = m.get(Parameter.get(e.getKey()));
if (sums == null)
throw new IllegalArgumentException("sums == null, line=" + line + ", e=" + e);
sums.add(e.getValue());
}
}