org.apache.ignite.internal.util.typedef.F.sumInt()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(59)

本文整理了Java中org.apache.ignite.internal.util.typedef.F.sumInt()方法的一些代码示例,展示了F.sumInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。F.sumInt()方法的具体详情如下:
包路径:org.apache.ignite.internal.util.typedef.F
类名称:F
方法名:sumInt

F.sumInt介绍

暂无

代码示例

代码示例来源:origin: apache/ignite

/**
 * Gets total received messages count.
 *
 * @return Total received messages count.
 */
public synchronized int totalReceivedMessages() {
  return F.sumInt(receivedMessages().values());
}

代码示例来源:origin: apache/ignite

/**
 * Gets total processed messages count.
 *
 * @return Total processed messages count.
 */
public synchronized int totalProcessedMessages() {
  return F.sumInt(processedMessages().values());
}

代码示例来源:origin: apache/ignite

/**
 * Calculate uniformity as standard deviation. See: http://en.wikipedia.org/wiki/Standard_deviation.
 *
 * @return Uniformity value as number in {@code 0..1} range.
 */
public double calc() {
  if (counters.isEmpty())
    return -1;
  else {
    int cap = (int)(fileSize / blockSize + (fileSize % blockSize > 0 ? 1 : 0));
    capacity(cap);
    int sz = counters.size();
    int n = F.sumInt(counters);
    double mean = 1.0 / sz;
    // Calc standard deviation for block read frequency: SQRT(SUM(Freq_i - Mean)^2 / K)
    // where Mean = 1 / K
    //       K - Number of blocks
    //       Freq_i = Counter_i / N
    //       N - Sum of all counters
    double sigma = 0;
    for (Integer counter : counters)
      sigma += Math.pow(counter.doubleValue() / n - mean, 2);
    sigma = Math.sqrt(sigma / sz);
    // Calc uniformity coefficient.
    return 1.0 - sigma;
  }
}

代码示例来源:origin: apache/ignite

/**
   * @throws Exception If failed.
   */
  @Test
  public void testCallWithProducer() throws Exception {
    Collection<Integer> args = Arrays.asList(1, 2, 3);

    Collection<Integer> res = grid().compute().apply(new C1<Integer, Integer>() {
      @Override public Integer apply(Integer arg) {
        ids.add(this);

        return 10 + arg;
      }
    }, args);

    assertEquals(36, F.sumInt(res));
    assertEquals(3, ids.size());
  }
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testAffinityCall() throws Exception {
  Collection<Integer> res = new ArrayList<>();
  for (int i : F.asList(1, 2, 3)) {
    res.add(grid().compute().affinityCall(DEFAULT_CACHE_NAME, i, new IgniteCallable<Integer>() {
      @Override public Integer call() {
        ids.add(this);
        return 10;
      }
    }));
  }
  assertEquals(30, F.sumInt(res));
  assertEquals(3, ids.size());
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testCall() throws Exception {
  Collection<Integer> res = grid().compute().apply(new C1<Integer, Integer>() {
    @Override public Integer apply(Integer arg) {
      ids.add(this);
      return 10 + arg;
    }
  }, F.asList(1, 2, 3));
  assertEquals(36, F.sumInt(res));
  assertEquals(3, ids.size());
}

代码示例来源:origin: org.apache.ignite/ignite-core

/**
 * Gets total received messages count.
 *
 * @return Total received messages count.
 */
public synchronized int totalReceivedMessages() {
  return F.sumInt(receivedMessages().values());
}

代码示例来源:origin: org.apache.ignite/ignite-core

/**
 * Gets total processed messages count.
 *
 * @return Total processed messages count.
 */
public synchronized int totalProcessedMessages() {
  return F.sumInt(processedMessages().values());
}

代码示例来源:origin: org.apache.ignite/ignite-core

/**
 * Calculate uniformity as standard deviation. See: http://en.wikipedia.org/wiki/Standard_deviation.
 *
 * @return Uniformity value as number in {@code 0..1} range.
 */
public double calc() {
  if (counters.isEmpty())
    return -1;
  else {
    int cap = (int)(fileSize / blockSize + (fileSize % blockSize > 0 ? 1 : 0));
    capacity(cap);
    int sz = counters.size();
    int n = F.sumInt(counters);
    double mean = 1.0 / sz;
    // Calc standard deviation for block read frequency: SQRT(SUM(Freq_i - Mean)^2 / K)
    // where Mean = 1 / K
    //       K - Number of blocks
    //       Freq_i = Counter_i / N
    //       N - Sum of all counters
    double sigma = 0;
    for (Integer counter : counters)
      sigma += Math.pow(counter.doubleValue() / n - mean, 2);
    sigma = Math.sqrt(sigma / sz);
    // Calc uniformity coefficient.
    return 1.0 - sigma;
  }
}

相关文章