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


Java ImmutableRangeMap类代码示例

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


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

示例1: testAdd_positiveThenNegativeValue

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
@Test
public void testAdd_positiveThenNegativeValue() {
  distribution.add(2.0);
  distribution.add(-2.0);

  assertThat(distribution.count()).isEqualTo(2);
  assertThat(distribution.mean()).isWithin(0.0).of(0.0);
  assertThat(distribution.sumOfSquaredDeviation()).isWithin(0.0).of(8.0);
  assertThat(distribution.intervalCounts())
      .isEqualTo(
          ImmutableRangeMap.<Double, Long>builder()
              .put(Range.lessThan(3.0), 2L)
              .put(Range.closedOpen(3.0, 5.0), 0L)
              .put(Range.atLeast(5.0), 0L)
              .build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:17,代码来源:MutableDistributionTest.java

示例2: testAdd_wideRangeOfValues

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
@Test
public void testAdd_wideRangeOfValues() {
  distribution.add(2.0);
  distribution.add(16.0);
  distribution.add(128.0, 5);
  distribution.add(1024.0, 0);

  assertThat(distribution.count()).isEqualTo(7);
  assertThat(distribution.mean()).isWithin(0.0).of(94.0);
  assertThat(distribution.sumOfSquaredDeviation()).isWithin(0.0).of(20328.0);
  assertThat(distribution.intervalCounts())
      .isEqualTo(
          ImmutableRangeMap.<Double, Long>builder()
              .put(Range.lessThan(3.0), 1L)
              .put(Range.closedOpen(3.0, 5.0), 0L)
              .put(Range.atLeast(5.0), 6L)
              .build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:19,代码来源:MutableDistributionTest.java

示例3: buildBlockMap

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
/**
 * Builds a mapping of block locations to file byte range
 */
private ImmutableRangeMap<Long,BlockLocation> buildBlockMap(FileStatus status) throws IOException {
  final Timer.Context context = metrics.timer(BLOCK_MAP_BUILDER_TIMER).time();
  BlockLocation[] blocks;
  ImmutableRangeMap<Long,BlockLocation> blockMap;
  blocks = fs.getFileBlockLocations(status, 0 , status.getLen());
  ImmutableRangeMap.Builder<Long, BlockLocation> blockMapBuilder = new ImmutableRangeMap.Builder<Long,BlockLocation>();
  for (BlockLocation block : blocks) {
    long start = block.getOffset();
    long end = start + block.getLength();
    Range<Long> range = Range.closedOpen(start, end);
    blockMapBuilder = blockMapBuilder.put(range, block);
  }
  blockMap = blockMapBuilder.build();
  blockMapMap.put(status.getPath(), blockMap);
  context.stop();
  return blockMap;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:21,代码来源:BlockMapBuilder.java

示例4: getRangeMap

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
protected RangeMap<Integer, ScenarioDefinition> getRangeMap(FeatureWrapper feature) {
	List<ScenarioDefinition> children = Lists.newArrayList(feature.getChildren());

	ImmutableRangeMap.Builder<Integer, ScenarioDefinition> builder = ImmutableRangeMap.builder();
	while (!children.isEmpty()) {
		ScenarioDefinition child = children.remove(0);
		Location location = child.getLocation();
		Integer childStart = location.getLine();

		ScenarioDefinition sibling = children.isEmpty() ? null : children.get(0);
		Location siblingLocation = null == sibling ? null : sibling.getLocation();
		Integer siblingStart = null == siblingLocation ? null : siblingLocation.getLine();

		Range<Integer> range = null == siblingStart ? Range.atLeast(childStart) : Range.closedOpen(childStart, siblingStart);
		builder.put(range, child);
	}
	return builder.build();
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:19,代码来源:DefaultMixology.java

示例5: buildBlockMap

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
/**
 * Builds a mapping of block locations to file byte range
 */
private ImmutableRangeMap<Long,BlockLocation> buildBlockMap(FileStatus status) throws IOException {
  final Timer.Context context = metrics.timer(BLOCK_MAP_BUILDER_TIMER).time();
  BlockLocation[] blocks;
  ImmutableRangeMap<Long,BlockLocation> blockMap;
  blocks = fs.getFileBlockLocations(status, 0 , status.getLen());
  ImmutableRangeMap.Builder<Long, BlockLocation> blockMapBuilder = new ImmutableRangeMap.Builder<>();
  for (BlockLocation block : blocks) {
    long start = block.getOffset();
    long end = start + block.getLength();
    Range<Long> range = Range.closedOpen(start, end);
    blockMapBuilder = blockMapBuilder.put(range, block);
  }
  blockMap = blockMapBuilder.build();
  blockMapMap.put(status.getPath(), blockMap);
  context.stop();
  return blockMap;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:BlockMapBuilder.java

示例6: create

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
public static <V> BinGenerator<V> create(
        Random random, Iterable<? extends Pair<Float, ? extends V>> weightedValues) {
    final ImmutableRangeMap.Builder<Float, V> bins = ImmutableRangeMap.builder();
    Float lower = Float.valueOf(0.0f);
    for (Pair<Float, ? extends V> weightedValue: weightedValues) {
        if (weightedValue.first().floatValue() <= 0.0f) {
            continue;
        }
        Float upper = Float.valueOf(Floats.min(1.0f, lower.floatValue() + weightedValue.first().floatValue()));
        checkArgument(upper.floatValue() > lower.floatValue());
        Range<Float> range = Range.closedOpen(lower, upper);
        bins.put(range, weightedValue.second());
        lower = upper;
    }
    checkArgument(Float.compare(lower.floatValue(), 1.0f) == 0);
    return new BinGenerator<V>(random, bins.build());
}
 
开发者ID:lisaglendenning,项目名称:zookeeper-lite,代码行数:18,代码来源:BinGenerator.java

示例7: create

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
@VisibleForTesting
static ImmutableDistribution create(
    double mean,
    double sumOfSquaredDeviation,
    long count,
    ImmutableRangeMap<Double, Long> intervalCounts,
    DistributionFitter distributionFitter) {
  checkDouble(mean);
  checkDouble(sumOfSquaredDeviation);
  checkArgument(count >= 0);

  return new AutoValue_ImmutableDistribution(
      mean, sumOfSquaredDeviation, count, intervalCounts, distributionFitter);
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:15,代码来源:ImmutableDistribution.java

示例8: testAdd_oneValue

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
@Test
public void testAdd_oneValue() {
  distribution.add(5.0);

  assertThat(distribution.count()).isEqualTo(1);
  assertThat(distribution.mean()).isWithin(0.0).of(5.0);
  assertThat(distribution.sumOfSquaredDeviation()).isWithin(0.0).of(0);
  assertThat(distribution.intervalCounts())
      .isEqualTo(
          ImmutableRangeMap.<Double, Long>builder()
              .put(Range.lessThan(3.0), 0L)
              .put(Range.closedOpen(3.0, 5.0), 0L)
              .put(Range.atLeast(5.0), 1L)
              .build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:16,代码来源:MutableDistributionTest.java

示例9: testAdd_zero

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
@Test
public void testAdd_zero() {
  distribution.add(0.0);

  assertThat(distribution.count()).isEqualTo(1);
  assertThat(distribution.mean()).isWithin(0.0).of(0.0);
  assertThat(distribution.sumOfSquaredDeviation()).isWithin(0.0).of(0);
  assertThat(distribution.intervalCounts())
      .isEqualTo(
          ImmutableRangeMap.<Double, Long>builder()
              .put(Range.lessThan(3.0), 1L)
              .put(Range.closedOpen(3.0, 5.0), 0L)
              .put(Range.atLeast(5.0), 0L)
              .build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:16,代码来源:MutableDistributionTest.java

示例10: testAdd_multipleOfOneValue

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
@Test
public void testAdd_multipleOfOneValue() {
  distribution.add(4.0, 2);

  assertThat(distribution.count()).isEqualTo(2);
  assertThat(distribution.mean()).isWithin(0.0).of(4.0);
  assertThat(distribution.sumOfSquaredDeviation()).isWithin(0.0).of(0);
  assertThat(distribution.intervalCounts())
      .isEqualTo(
          ImmutableRangeMap.<Double, Long>builder()
              .put(Range.lessThan(3.0), 0L)
              .put(Range.closedOpen(3.0, 5.0), 2L)
              .put(Range.atLeast(5.0), 0L)
              .build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:16,代码来源:MutableDistributionTest.java

示例11: testAdd_fitterWithNoFiniteIntervals_underflowValue_returnsUnderflowInterval

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
@Test
public void testAdd_fitterWithNoFiniteIntervals_underflowValue_returnsUnderflowInterval()
    throws Exception {
  MutableDistribution distribution =
      new MutableDistribution(CustomFitter.create(ImmutableSet.of(5.0)));

  distribution.add(3.0);

  assertThat(distribution.intervalCounts())
      .isEqualTo(
          ImmutableRangeMap.<Double, Long>builder()
              .put(Range.lessThan(5.0), 1L)
              .put(Range.atLeast(5.0), 0L)
              .build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:16,代码来源:MutableDistributionTest.java

示例12: testAdd_noFiniteIntervals_overflowValue_returnsOverflowInterval

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
@Test
public void testAdd_noFiniteIntervals_overflowValue_returnsOverflowInterval() throws Exception {
  MutableDistribution distribution =
      new MutableDistribution(CustomFitter.create(ImmutableSet.of(5.0)));

  distribution.add(10.0);

  assertThat(distribution.intervalCounts())
      .isEqualTo(
          ImmutableRangeMap.<Double, Long>builder()
              .put(Range.lessThan(5.0), 0L)
              .put(Range.atLeast(5.0), 1L)
              .build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:15,代码来源:MutableDistributionTest.java

示例13: testAdd_noFiniteIntervals_edgeValue_returnsOverflowInterval

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
@Test
public void testAdd_noFiniteIntervals_edgeValue_returnsOverflowInterval() throws Exception {
  MutableDistribution distribution =
      new MutableDistribution(CustomFitter.create(ImmutableSet.of(2.0)));

  distribution.add(2.0);

  assertThat(distribution.intervalCounts())
      .isEqualTo(
          ImmutableRangeMap.<Double, Long>builder()
              .put(Range.lessThan(2.0), 0L)
              .put(Range.atLeast(2.0), 1L)
              .build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:15,代码来源:MutableDistributionTest.java

示例14: testAdd_oneFiniteInterval_underflowValue_returnsUnderflowInterval

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
@Test
public void testAdd_oneFiniteInterval_underflowValue_returnsUnderflowInterval() throws Exception {
  MutableDistribution distribution =
      new MutableDistribution(CustomFitter.create(ImmutableSet.of(1.0, 5.0)));

  distribution.add(0.0);

  assertThat(distribution.intervalCounts())
      .isEqualTo(
          ImmutableRangeMap.<Double, Long>builder()
              .put(Range.lessThan(1.0), 1L)
              .put(Range.closedOpen(1.0, 5.0), 0L)
              .put(Range.atLeast(5.0), 0L)
              .build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:16,代码来源:MutableDistributionTest.java

示例15: testAdd_oneFiniteInterval_overflowValue_returnsOverflowInterval

import com.google.common.collect.ImmutableRangeMap; //导入依赖的package包/类
@Test
public void testAdd_oneFiniteInterval_overflowValue_returnsOverflowInterval() throws Exception {
  MutableDistribution distribution =
      new MutableDistribution(CustomFitter.create(ImmutableSet.of(1.0, 5.0)));

  distribution.add(10.0);

  assertThat(distribution.intervalCounts())
      .isEqualTo(
          ImmutableRangeMap.<Double, Long>builder()
              .put(Range.lessThan(1.0), 0L)
              .put(Range.closedOpen(1.0, 5.0), 0L)
              .put(Range.atLeast(5.0), 1L)
              .build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:16,代码来源:MutableDistributionTest.java


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