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


Java ImmutableRangeMap.Builder方法代码示例

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


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

示例1: 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

示例2: 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

示例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<>();
  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

示例4: 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

示例5: chooseShuffledMaterial

import com.google.common.collect.ImmutableRangeMap; //导入方法依赖的package包/类
MaterialData chooseShuffledMaterial() {
    ImmutableRangeMap.Builder<Double, MaterialData> weightsBuilder = ImmutableRangeMap.builder();
    double sum = 0d;
    for(MaterialData material : shuffleableMaterialDeficit.materials()) {
        double weight = shuffleableMaterialDeficit.get(material);
        if(weight > 0) {
            weightsBuilder.put(Range.closedOpen(sum, sum + weight), material);
            sum += weight;
        }
    }
    RangeMap<Double, MaterialData> weights = weightsBuilder.build();
    return weights.get(match.getRandom().nextDouble() * sum);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:14,代码来源:Renewable.java

示例6: testBuildRangeMap

import com.google.common.collect.ImmutableRangeMap; //导入方法依赖的package包/类
@Test
public void testBuildRangeMap() {
  BlockLocation[] blocks = buildBlockLocations(new String[4], 256*1024*1024);
  long tA = System.nanoTime();
  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);
  }
  ImmutableRangeMap<Long,BlockLocation> map = blockMapBuilder.build();
  long tB = System.nanoTime();
  System.out.println(String.format("Took %f ms to build range map", (float)(tB - tA) / 1e6));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:16,代码来源:TestAffinityCalculator.java

示例7: testBuildRangeMap

import com.google.common.collect.ImmutableRangeMap; //导入方法依赖的package包/类
@Test
public void testBuildRangeMap() {
  BlockLocation[] blocks = buildBlockLocations(new String[4], 256*1024*1024);
  long tA = System.nanoTime();
  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);
  }
  ImmutableRangeMap<Long,BlockLocation> map = blockMapBuilder.build();
  long tB = System.nanoTime();
  System.out.println(String.format("Took %f ms to build range map", (tB - tA) / 1e6));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:16,代码来源:TestAffinityCalculator.java

示例8: create

import com.google.common.collect.ImmutableRangeMap; //导入方法依赖的package包/类
public static LineMap create(String source) {
  int last = 0;
  int line = 1;
  ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
  for (int idx = 0; idx < source.length(); idx++) {
    char ch = source.charAt(idx);
    switch (ch) {
        // handle CR line endings
      case '\r':
        // ...and CRLF
        if (idx + 1 < source.length() && source.charAt(idx + 1) == '\n') {
          idx++;
        }
        // falls through
      case '\n':
        builder.put(Range.closedOpen(last, idx + 1), line++);
        last = idx + 1;
        break;
      default:
        break;
    }
  }
  // no trailing newline
  if (last < source.length()) {
    builder.put(Range.closedOpen(last, source.length()), line++);
  }
  return new LineMap(source, builder.build());
}
 
开发者ID:google,项目名称:turbine,代码行数:29,代码来源:LineMap.java

示例9: testBuildRangeMap

import com.google.common.collect.ImmutableRangeMap; //导入方法依赖的package包/类
@Test
public void testBuildRangeMap() {
  BlockLocation[] blocks = buildBlockLocations(new String[4], 256*1024*1024);
  long tA = System.nanoTime();
  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);
  }
  ImmutableRangeMap<Long,BlockLocation> map = blockMapBuilder.build();
  long tB = System.nanoTime();
  System.out.println(String.format("Took %f ms to build range map", (tB - tA) / 1e6));
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:16,代码来源:TestAffinityCalculator.java


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