當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。