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


Java Summation类代码示例

本文整理汇总了Java中org.apache.hadoop.examples.pi.math.Summation的典型用法代码示例。如果您正苦于以下问题:Java Summation类的具体用法?Java Summation怎么用?Java Summation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Summation类属于org.apache.hadoop.examples.pi.math包,在下文中一共展示了Summation类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: valueOf

import org.apache.hadoop.examples.pi.math.Summation; //导入依赖的package包/类
/** Covert a String to a TaskResult */
public static TaskResult valueOf(String s) {
  int i = 0;
  int j = s.indexOf(", duration=");
  if (j < 0)
    throw new IllegalArgumentException("i=" + i + ", j=" + j + " < 0, s=" + s);
  final Summation sigma = Summation.valueOf(Util.parseStringVariable("sigma", s.substring(i, j)));

  i = j + 2;
  j = s.indexOf("(", i);
  if (j < 0)
    throw new IllegalArgumentException("i=" + i + ", j=" + j + " < 0, s=" + s);
  final long duration = Util.parseLongVariable("duration", s.substring(i, j));

  return new TaskResult(sigma, duration);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TaskResult.java

示例2: execute

import org.apache.hadoop.examples.pi.math.Summation; //导入依赖的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

示例3: compute

import org.apache.hadoop.examples.pi.math.Summation; //导入依赖的package包/类
/** Compute sigma */
static void compute(Summation sigma,
    TaskInputOutputContext<?, ?, NullWritable, TaskResult> context
    ) throws IOException, InterruptedException {
  String s;
  LOG.info(s = "sigma=" + sigma);
  context.setStatus(s);

  final long start = System.currentTimeMillis();
  sigma.compute();
  final long duration = System.currentTimeMillis() - start;
  final TaskResult result = new TaskResult(sigma, duration);

  LOG.info(s = "result=" + result);
  context.setStatus(s);
  context.write(NullWritable.get(), result);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:DistSum.java

示例4: getSplits

import org.apache.hadoop.examples.pi.math.Summation; //导入依赖的package包/类
/** Partitions the summation into parts and then return them as splits */
@Override
public List<InputSplit> getSplits(JobContext context) {
  //read sigma from conf
  final Configuration conf = context.getConfiguration();
  final Summation sigma = SummationWritable.read(DistSum.class, conf); 
  final int nParts = conf.getInt(N_PARTS, 0);
  
  //create splits
  final List<InputSplit> splits = new ArrayList<InputSplit>(nParts);
  final Summation[] parts = sigma.partition(nParts);
  for(int i = 0; i < parts.length; ++i) {
    splits.add(new SummationSplit(parts[i]));
    //LOG.info("parts[" + i + "] = " + parts[i]);
  }
  return splits;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:DistSum.java

示例5: createJob

import org.apache.hadoop.examples.pi.math.Summation; //导入依赖的package包/类
/** Create a job */
private Job createJob(String name, Summation sigma) throws IOException {
  final Job job = Job.getInstance(getConf(), parameters.remoteDir + "/" +
                                  name);
  final Configuration jobconf = job.getConfiguration();
  job.setJarByClass(DistSum.class);
  jobconf.setInt(N_PARTS, parameters.nParts);
  SummationWritable.write(sigma, DistSum.class, jobconf);

  // disable task timeout
  jobconf.setLong(MRJobConfig.TASK_TIMEOUT, 0);
  // do not use speculative execution
  jobconf.setBoolean(MRJobConfig.MAP_SPECULATIVE, false);
  jobconf.setBoolean(MRJobConfig.REDUCE_SPECULATIVE, false);

  return job; 
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:DistSum.java

示例6: createJob

import org.apache.hadoop.examples.pi.math.Summation; //导入依赖的package包/类
/** Create a job */
private Job createJob(String name, Summation sigma) throws IOException {
  final Job job = new Job(getConf(), parameters.remoteDir + "/" + name);
  final Configuration jobconf = job.getConfiguration();
  job.setJarByClass(DistSum.class);
  jobconf.setInt(N_PARTS, parameters.nParts);
  SummationWritable.write(sigma, DistSum.class, jobconf);

  // disable task timeout
  jobconf.setLong(MRJobConfig.TASK_TIMEOUT, 0);
  // do not use speculative execution
  jobconf.setBoolean(MRJobConfig.MAP_SPECULATIVE, false);
  jobconf.setBoolean(MRJobConfig.REDUCE_SPECULATIVE, false);

  return job; 
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:17,代码来源:DistSum.java


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