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


Java Range.lowerEndpoint方法代码示例

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


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

示例1: makeKToIJ

import com.google.common.collect.Range; //导入方法依赖的package包/类
/**
 * Given an {@code InputOutput}, compute the map from tok indices to line ranges.
 *
 * @param put the {@code InputOutput}
 * @param kN the number of tokens
 * @return the map from {@link com.google.googlejavaformat.java.JavaInput.Tok} indices to line
 *     ranges in this {@code put}
 */
public static Map<Integer, Range<Integer>> makeKToIJ(InputOutput put, int kN) {
  Map<Integer, Range<Integer>> map = new HashMap<>();
  int ijN = put.getLineCount();
  for (int ij = 0; ij <= ijN; ij++) {
    Range<Integer> range = put.getRanges(ij).canonical(INTEGERS);
    for (int k = range.lowerEndpoint(); k < range.upperEndpoint(); k++) {
      if (map.containsKey(k)) {
        map.put(k, Range.closedOpen(map.get(k).lowerEndpoint(), ij + 1));
      } else {
        map.put(k, Range.closedOpen(ij, ij + 1));
      }
    }
  }
  return map;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:InputOutput.java

示例2: matches

import com.google.common.collect.Range; //导入方法依赖的package包/类
public boolean matches(DrillFileSystem fs, FileStatus status) throws IOException{
  if (ranges.isEmpty()) {
    return false;
  }
  final Range<Long> fileRange = Range.closedOpen( 0L, status.getLen());

  try (FSDataInputStream is = fs.open(status.getPath())) {
    for(RangeMagics rMagic : ranges) {
      Range<Long> r = rMagic.range;
      if (!fileRange.encloses(r)) {
        continue;
      }
      int len = (int) (r.upperEndpoint() - r.lowerEndpoint());
      byte[] bytes = new byte[len];
      is.readFully(r.lowerEndpoint(), bytes);
      for (byte[] magic : rMagic.magics) {
        if (Arrays.equals(magic, bytes)) {
          return true;
        }
      }
    }
  }
  return false;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:25,代码来源:BasicFormatMatcher.java

示例3: mergeRanges

import com.google.common.collect.Range; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static List<KeyRange> mergeRanges(List<KeyRange> ranges) {
  if (ranges == null || ranges.isEmpty() || ranges.size() == 1) {
    return ranges;
  }

  Range merged = ranges
      .stream()
      .map(KeyRangeUtils::toRange)
      .reduce(Range::span).get();

  List<KeyRange> keyRanges = new ArrayList<>();
  try {
    Comparables.ComparableByteString lower =
        (Comparables.ComparableByteString) merged.lowerEndpoint();
    Comparables.ComparableByteString upper =
        (Comparables.ComparableByteString) merged.upperEndpoint();

    keyRanges.add(makeCoprocRange(lower.getByteString(), upper.getByteString()));
  } catch (Exception ignored) {}

  return keyRanges;
}
 
开发者ID:pingcap,项目名称:tikv-client-lib-java,代码行数:24,代码来源:KeyRangeUtils.java

示例4: getSplitsRange

import com.google.common.collect.Range; //导入方法依赖的package包/类
public static FindByRange<DatasetSplitId> getSplitsRange(DatasetConfig datasetConfig) {
  final String datasetId = datasetConfig.getId().getId();
  Range<String> range = getSplitStringRange(datasetConfig);
  final DatasetSplitId start = new DatasetSplitId(datasetId, range.lowerEndpoint());
  final DatasetSplitId end = new DatasetSplitId(datasetId, range.upperEndpoint());

  return new FindByRange<DatasetSplitId>()
    .setStart(start, true)
    .setEnd(end, false);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:DatasetSplitId.java

示例5: createWordLists

import com.google.common.collect.Range; //导入方法依赖的package包/类
private List<List<String>> createWordLists(List<String> words, Range<Integer> range) {
    List<List<String>> wordsPermutated = Lists.newArrayList();
    for (int i = range.lowerEndpoint(); i <= range.upperEndpoint(); i++) {
        if (i > 0) {
            LinkedList<String> currPermutationHead = createWordsPermutation(words, i, Ending.HEAD);
            wordsPermutated.add(currPermutationHead);
            LinkedList<String> currPermutationTail = createWordsPermutation(words, i, Ending.TAIL);
            wordsPermutated.add(currPermutationTail);
        }
        LinkedList<String> currPermutationBoth = createWordsPermutation(words, i, Ending.BOTH);
        wordsPermutated.add(currPermutationBoth);
    }
    return wordsPermutated;
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:15,代码来源:WordsPermutationUtil.java

示例6: parseRandom

import com.google.common.collect.Range; //导入方法依赖的package包/类
@MethodParser("random")
public Filter parseRandom(Element el) throws InvalidXMLException {
    Node node = new Node(el);
    Range<Double> chance;
    try {
        chance = Range.closedOpen(0d, XMLUtils.parseNumber(node, Double.class));
    } catch(InvalidXMLException e) {
        chance = XMLUtils.parseNumericRange(node, Double.class);
    }

    Range<Double> valid = Range.closed(0d, 1d);
    if (valid.encloses(chance)) {
        return proto.isNoOlderThan(ProtoVersions.EVENT_QUERIES) ? new RandomFilter(chance)
                                                                : new LegacyRandomFilter(chance);
    } else {
        double lower = chance.hasLowerBound() ? chance.lowerEndpoint() : Double.NEGATIVE_INFINITY;
        double upper = chance.hasUpperBound() ? chance.upperEndpoint() : Double.POSITIVE_INFINITY;
        double invalid;
        if(!valid.contains(lower)) {
            invalid = lower;
        } else {
            invalid = upper;
        }

        throw new InvalidXMLException("chance value (" + invalid + ") is not between 0 and 1", el);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:28,代码来源:FilterDefinitionParser.java

示例7: describe

import com.google.common.collect.Range; //导入方法依赖的package包/类
/**
 * Return an english phrase describing the given {@link Range} e.g.
 *
 *     Range.all()                      -> "unbounded"
 *     Range.singleton(3)               -> "3"
 *     Range.atLeast(3)                 -> "at least 3"
 *     Range.closedOpen(3, 7)           -> "at least 3 and less than 7"
 *     Range.closed(3, 7)               -> "between 3 and 7"
 */
public static String describe(Range<?> range) {
    if(range.hasLowerBound() && range.hasUpperBound() && range.lowerBoundType() == BoundType.CLOSED && range.upperBoundType() == BoundType.CLOSED) {
        if(range.lowerEndpoint().equals(range.upperEndpoint())) {
            // singleton
            return range.lowerEndpoint().toString();
        } else {
            // closed-closed
            return "between " + range.lowerEndpoint() + " and " + range.upperEndpoint();
        }
    }

    final List<String> parts = new ArrayList<>(2);

    if(range.hasLowerBound()) {
        parts.add((range.lowerBoundType() == BoundType.CLOSED ? "at least " : "more than ") + range.lowerEndpoint());
    }

    if(range.hasUpperBound()) {
        parts.add((range.upperBoundType() == BoundType.CLOSED ? "at most " : "less than ") + range.upperEndpoint());
    }

    switch(parts.size()) {
        case 0: return "unbounded";
        case 1: return parts.get(0);
        default: return parts.get(0) + " and " + parts.get(1);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:37,代码来源:Ranges.java

示例8: expandToBreakableRegions

import com.google.common.collect.Range; //导入方法依赖的package包/类
/**
 * Expand a token range to start and end on acceptable boundaries for re-formatting.
 *
 * @param iRange the {@link Range} of tokens
 * @return the expanded token range
 */
private Range<Integer> expandToBreakableRegions(Range<Integer> iRange) {
    // The original line range.
    int loTok = iRange.lowerEndpoint();
    int hiTok = iRange.upperEndpoint() - 1;

    // Expand the token indices to formattable boundaries (e.g. edges of statements).
    if (!partialFormatRanges.contains(loTok) || !partialFormatRanges.contains(hiTok)) {
        return EMPTY_RANGE;
    }
    loTok = partialFormatRanges.rangeContaining(loTok).lowerEndpoint();
    hiTok = partialFormatRanges.rangeContaining(hiTok).upperEndpoint();
    return Range.closedOpen(loTok, hiTok + 1);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:JavaOutput.java

示例9: doBetweenSharding

import com.google.common.collect.Range; //导入方法依赖的package包/类
@Override
public Collection<String> doBetweenSharding(final Collection<String> dataSourceNames, final ShardingValue<Integer> shardingValue) {
    Collection<String> result = new LinkedHashSet<>(dataSourceNames.size());
    Range<Integer> range = shardingValue.getValueRange();
    for (Integer i = range.lowerEndpoint(); i <= range.upperEndpoint(); i++) {
        for (String each : dataSourceNames) {
            if (each.endsWith(i % 2 + "")) {
                result.add(each);
            }
        }
    }
    return result;
}
 
开发者ID:rpgmakervx,项目名称:slardar,代码行数:14,代码来源:ModuloTableShardingAlgorithm.java

示例10: matches

import com.google.common.collect.Range; //导入方法依赖的package包/类
public boolean matches(FileSystemWrapper fs, FileStatus status) throws IOException{
  if (ranges.isEmpty() || status.isDirectory()) {
    return false;
  }
  // walk all the way down in the symlinks until a hard entry is reached
  FileStatus current = status;
  while (current.isSymlink()) {
    current = fs.getFileStatus(status.getSymlink());
  }
  // if hard entry is not a file nor can it be a symlink then it is not readable simply deny matching.
  if (!current.isFile()) {
    return false;
  }

  final Range<Long> fileRange = Range.closedOpen( 0L, status.getLen());

  try (FSDataInputStream is = fs.open(status.getPath())) {
    for(RangeMagics rMagic : ranges) {
      Range<Long> r = rMagic.range;
      if (!fileRange.encloses(r)) {
        continue;
      }
      int len = (int) (r.upperEndpoint() - r.lowerEndpoint());
      byte[] bytes = new byte[len];
      is.readFully(r.lowerEndpoint(), bytes);
      for (byte[] magic : rMagic.magics) {
        if (Arrays.equals(magic, bytes)) {
          return true;
        }
      }
    }
  }
  return false;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:35,代码来源:BasicFormatMatcher.java

示例11: computeLocality

import com.google.common.collect.Range; //导入方法依赖的package包/类
private void computeLocality(ParquetMetadata footer) throws ExecutionSetupException {
  try {
    BlockMetaData block = footer.getBlocks().get(readEntry.getRowGroupIndex());

    BlockLocation[] blockLocations = fs.getFileBlockLocations(new Path(readEntry.getPath()), block.getStartingPos(), block.getCompressedSize());

    String localHost = InetAddress.getLocalHost().getCanonicalHostName();

    List<Range<Long>> intersectingRanges = new ArrayList<>();

    Range<Long> rowGroupRange = Range.openClosed(block.getStartingPos(), block.getStartingPos() + block.getCompressedSize());

    for (BlockLocation loc : blockLocations) {
      for (String host : loc.getHosts()) {
        if (host.equals(localHost)) {
          intersectingRanges.add(Range.closedOpen(loc.getOffset(), loc.getOffset() + loc.getLength()).intersection(rowGroupRange));
        }
      }
    }

    long totalIntersect = 0;
    for (Range<Long> range : intersectingRanges) {
      totalIntersect += (range.upperEndpoint() - range.lowerEndpoint());
    }
    if (totalIntersect < block.getCompressedSize()) {
      context.getStats().addLongStat(Metric.NUM_REMOTE_READERS, 1);
    } else {
      context.getStats().addLongStat(Metric.NUM_REMOTE_READERS, 0);
    }
  } catch (IOException e) {
    throw new ExecutionSetupException(e);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:34,代码来源:UnifiedParquetReader.java

示例12: isViewportAboveContainer

import com.google.common.collect.Range; //导入方法依赖的package包/类
private boolean isViewportAboveContainer(Range<Integer> container, Range<Integer> viewport) {
    return container.upperEndpoint() < viewport.lowerEndpoint();
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:4,代码来源:CenterPositionFinder.java

示例13: needMinimum

import com.google.common.collect.Range; //导入方法依赖的package包/类
public static int needMinimum(Range<Integer> range) {
    assertLowerBound(range);
    return range.lowerBoundType() == BoundType.CLOSED ? range.lowerEndpoint()
                                                      : range.lowerEndpoint() + 1;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:6,代码来源:Ranges.java

示例14: needOpenMinimum

import com.google.common.collect.Range; //导入方法依赖的package包/类
public static int needOpenMinimum(Range<Integer> range) {
    assertLowerBound(range);
    return range.lowerBoundType() == BoundType.CLOSED ? range.lowerEndpoint() - 1
                                                      : range.lowerEndpoint();
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:6,代码来源:Ranges.java

示例15: getEndpointByteMap

import com.google.common.collect.Range; //导入方法依赖的package包/类
/**
 * For a given FileWork, calculate how many bytes are available on each on node endpoint
 *
 * @param work the FileWork to calculate endpoint bytes for
 * @throws IOException
 */
public EndpointByteMap getEndpointByteMap(FileWork work) throws IOException {
  Stopwatch watch = Stopwatch.createStarted();



  ImmutableRangeMap<Long,BlockLocation> blockMap = getBlockMap(work.getStatus());
  EndpointByteMapImpl endpointByteMap = new EndpointByteMapImpl();
  long start = work.getStart();
  long end = start + work.getLength();
  Range<Long> rowGroupRange = Range.closedOpen(start, end);

  // Find submap of ranges that intersect with the rowGroup
  ImmutableRangeMap<Long,BlockLocation> subRangeMap = blockMap.subRangeMap(rowGroupRange);

  // Iterate through each block in this submap and get the host for the block location
  for (Map.Entry<Range<Long>,BlockLocation> block : subRangeMap.asMapOfRanges().entrySet()) {
    String[] hosts;
    Range<Long> blockRange = block.getKey();
    try {
      hosts = block.getValue().getHosts();
    } catch (IOException ioe) {
      throw new RuntimeException("Failed to get hosts for block location", ioe);
    }
    Range<Long> intersection = rowGroupRange.intersection(blockRange);
    long bytes = intersection.upperEndpoint() - intersection.lowerEndpoint();

    // For each host in the current block location, add the intersecting bytes to the corresponding endpoint
    for (String host : hosts) {
      NodeEndpoint endpoint = getNodeEndpoint(host);
      if (endpoint != null) {
        endpointByteMap.add(endpoint, bytes);
      } else {
        logger.debug("Failure finding SabotNode running on host {}.  Skipping affinity to that host.", host);
      }
    }
  }

  logger.debug("FileWork group ({},{}) max bytes {}", work.getStatus().getPath(), work.getStart(), endpointByteMap.getMaxBytes());

  logger.debug("Took {} ms to set endpoint bytes", watch.stop().elapsed(TimeUnit.MILLISECONDS));
  return endpointByteMap;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:49,代码来源:BlockMapBuilder.java


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