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


Java Range.upperEndpoint方法代码示例

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


在下文中一共展示了Range.upperEndpoint方法的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: encodeTimeInterval

import com.google.common.collect.Range; //导入方法依赖的package包/类
private static TimeInterval encodeTimeInterval(Range<Instant> nativeInterval, Kind metricKind) {

    TimeInterval encodedInterval =
        new TimeInterval().setStartTime(nativeInterval.lowerEndpoint().toString());

    Instant endTimestamp =
        nativeInterval.isEmpty() && metricKind != Kind.GAUGE
            ? nativeInterval.upperEndpoint().plusMillis(1)
            : nativeInterval.upperEndpoint();

    return encodedInterval.setEndTime(endTimestamp.toString());
  }
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:13,代码来源:StackdriverWriter.java

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

示例7: format

import com.google.common.collect.Range; //导入方法依赖的package包/类
Collection<BaseComponent> format() {
    final ImmutableList.Builder<BaseComponent> lines = ImmutableList.builder();

    lines.add(new TranslatableComponent(
        "matchQuota.matchCounts",
        new Component(String.valueOf(matchesPlayed), ChatColor.AQUA),
        new Component(String.valueOf(quota.maximum()), ChatColor.AQUA)
    ));

    if(matchesRemaining() == 0) {
        lines.add(new TranslatableComponent(
            "matchQuota.nextMatch",
            new Component(PeriodFormats.briefNaturalApproximate(now, earliestJoinTime), ChatColor.AQUA)
        ));
    }

    if(!quota.premium()) {
        Range<Integer> premiumRange = getConfig().getPremiumMaximum();
        if(premiumRange != null) {
            if(premiumRange.upperEndpoint() == Integer.MAX_VALUE) {
                lines.add(Links.shopPlug("shop.plug.rankedMatches.unlimited"));
            } else {
                BaseComponent premiumLimit = new Component(String.valueOf(premiumRange.upperEndpoint()), ChatColor.AQUA);
                if(premiumRange.upperEndpoint().equals(premiumRange.lowerEndpoint())) {
                    lines.add(Links.shopPlug("shop.plug.rankedMatches.uniform", premiumLimit));
                } else {
                    lines.add(Links.shopPlug("shop.plug.rankedMatches.upto", premiumLimit));
                }
            }
        }
    }

    return lines.build();
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:35,代码来源:QuotaMatchModule.java

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

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

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

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

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

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

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

示例15: needMaximum

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


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