当前位置: 首页>>代码示例>>Java>>正文


Java Parameter类代码示例

本文整理汇总了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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:Parser.java

示例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));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:Parser.java

示例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");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:DistBbp.java

示例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;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:19,代码来源:Parser.java

示例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());
    }
  }
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:Parser.java


注:本文中的org.apache.hadoop.examples.pi.math.Bellard.Parameter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。