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


Java Container类代码示例

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


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

示例1: partition

import org.apache.hadoop.examples.pi.Container; //导入依赖的package包/类
private static <T extends Container<Summation>> Summation[] partition(
    Summation sigma, int nParts, List<T> existing) {
  final List<Summation> parts = new ArrayList<Summation>();
  if (existing == null || existing.isEmpty())
    parts.addAll(Arrays.asList(sigma.partition(nParts)));
  else {
    final long stepsPerPart = sigma.getSteps()/nParts;
    final List<Summation> remaining = sigma.remainingTerms(existing);

    for(Summation s : remaining) {
      final int n = (int)((s.getSteps() - 1)/stepsPerPart) + 1;
      parts.addAll(Arrays.asList(s.partition(n)));
    }
    
    for(Container<Summation> c : existing)
      parts.add(c.getElement());
    Collections.sort(parts);
  }
  return parts.toArray(new Summation[parts.size()]);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:Bellard.java

示例2: computePi

import org.apache.hadoop.examples.pi.Container; //导入依赖的package包/类
/** Compute bits of Pi from the results. */
public static <T extends Container<Summation>> double computePi(
    final long b, Map<Parameter, T> results) {
  if (results.size() != Parameter.values().length)
    throw new IllegalArgumentException("m.size() != Parameter.values().length"
        + ", m.size()=" + results.size()
        + "\n  m=" + results);

  double pi = 0;
  for(Parameter p : Parameter.values()) {
    final Summation sigma = results.get(p).getElement();
    final Sum s = new Sum(b, p, 1, null);
    s.setValue(sigma);
    pi = Modular.addMod(pi, s.getValue());
  }
  return pi;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:Bellard.java

示例3: Sum

import org.apache.hadoop.examples.pi.Container; //导入依赖的package包/类
/** Constructor */
private <T extends Container<Summation>> Sum(long b, Parameter p, int nParts, List<T> existing) {
  if (b < 0)
    throw new IllegalArgumentException("b = " + b + " < 0");
  if (nParts < 1)
    throw new IllegalArgumentException("nParts = " + nParts + " < 1");
  final long i = p.j == 1 && p.offsetE >= 0? 1 : 0;
  final long e = b + i*p.deltaE + p.offsetE;
  final long n = i*p.deltaN + p.j;

  this.parameter = p;
  this.sigma = new Summation(n, p.deltaN, e, p.deltaE, 0);
  this.parts = partition(sigma, nParts, existing);
  this.tail = new Tail(n, e);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:Bellard.java

示例4: getSums

import org.apache.hadoop.examples.pi.Container; //导入依赖的package包/类
/** Get the sums for the Bellard formula. */
public static <T extends Container<Summation>> Map<Parameter, Sum> getSums(
    long b, int partsPerSum, Map<Parameter, List<T>> existing) {
  final Map<Parameter, Sum> sums = new TreeMap<Parameter, Sum>();
  for(Parameter p : Parameter.values()) {
    final Sum s = new Sum(b, p, partsPerSum, existing.get(p));
    Util.out.println("put " + s);
    sums.put(p, s);
  }
  return sums;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:Bellard.java

示例5: remainingTerms

import org.apache.hadoop.examples.pi.Container; //导入依赖的package包/类
/** Find the remaining terms. */
public <T extends Container<Summation>> List<Summation> remainingTerms(List<T> sorted) {
  final List<Summation> results = new ArrayList<Summation>();
  Summation remaining = this;

  if (sorted != null)
    for(Container<Summation> c : sorted) {
      final Summation sigma = c.getElement();
      if (!remaining.contains(sigma))
        throw new IllegalArgumentException("!remaining.contains(s),"
            + "\n  remaining = " + remaining
            + "\n  s         = " + sigma          
            + "\n  this      = " + this
            + "\n  sorted    = " + sorted);

      final Summation s = new Summation(sigma.N.limit, N.delta, remaining.N.limit,
                                        sigma.E.limit, E.delta, remaining.E.limit);
      if (s.getSteps() > 0)
        results.add(s);
      remaining = new Summation(remaining.N.value, N.delta, sigma.N.value,
                                remaining.E.value, E.delta, sigma.E.value);
    }

  if (remaining.getSteps() > 0)
    results.add(remaining);

  return results;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:Summation.java


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