java.util.NavigableMap#lowerEntry ( )源码实例Demo

下面列出了java.util.NavigableMap#lowerEntry ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ambry   文件: StatsBasedCompactionPolicy.java
/**
 * Finds the best candidate to compact by finding the candidate with the best cost benefit ratio
 * @param validDataPerLogSegments the valid data size for each log segment in the form of a {@link NavigableMap} of segment names to
 * valid data sizes.
 * @param segmentCapacity Segment capacity of one {@link LogSegment}
 * @param segmentHeaderSize Segment header size of a {@link LogSegment}
 * @param maxBlobSize max blob size to factor in when calculating the cost benefit ratio
 * @return the {@link CostBenefitInfo} for the best candidate to compact. {@code null} if there isn't any.
 */
private CostBenefitInfo getBestCandidateToCompact(NavigableMap<String, Long> validDataPerLogSegments,
    long segmentCapacity, long segmentHeaderSize, long maxBlobSize) {
  Map.Entry<String, Long> firstEntry = validDataPerLogSegments.firstEntry();
  Map.Entry<String, Long> lastEntry = validDataPerLogSegments.lastEntry();
  CostBenefitInfo bestCandidateToCompact = null;
  while (firstEntry != null) {
    Map.Entry<String, Long> endEntry = lastEntry;
    while (endEntry != null && LogSegmentNameHelper.COMPARATOR.compare(firstEntry.getKey(), endEntry.getKey()) <= 0) {
      CostBenefitInfo costBenefitInfo =
          getCostBenefitInfo(firstEntry.getKey(), endEntry.getKey(), validDataPerLogSegments, segmentCapacity,
              segmentHeaderSize, maxBlobSize);
      if (costBenefitInfo.getBenefit() >= storeConfig.storeMinLogSegmentCountToReclaimToTriggerCompaction && (
          bestCandidateToCompact == null
              || costBenefitInfo.getCostBenefitRatio().compareTo(bestCandidateToCompact.getCostBenefitRatio()) < 0)) {
        bestCandidateToCompact = costBenefitInfo;
        logger.trace("Updating best candidate to compact to {} ", bestCandidateToCompact);
      }
      endEntry = validDataPerLogSegments.lowerEntry(endEntry.getKey());
    }
    firstEntry = validDataPerLogSegments.higherEntry(firstEntry.getKey());
  }
  return bestCandidateToCompact;
}
 
源代码2 项目: openjdk-jdk9   文件: TreeSubMapTest.java
/**
 * lowerEntry returns preceding entry.
 */
public void testLowerEntry() {
    NavigableMap map = map5();
    Map.Entry e1 = map.lowerEntry(three);
    assertEquals(two, e1.getKey());

    Map.Entry e2 = map.lowerEntry(six);
    assertEquals(five, e2.getKey());

    Map.Entry e3 = map.lowerEntry(one);
    assertNull(e3);

    Map.Entry e4 = map.lowerEntry(zero);
    assertNull(e4);
}
 
源代码3 项目: openjdk-jdk9   文件: TreeSubMapTest.java
/**
 * lowerEntry returns preceding entry.
 */
public void testDescendingLowerEntry() {
    NavigableMap map = dmap5();
    Map.Entry e1 = map.lowerEntry(m3);
    assertEquals(m2, e1.getKey());

    Map.Entry e2 = map.lowerEntry(m6);
    assertEquals(m5, e2.getKey());

    Map.Entry e3 = map.lowerEntry(m1);
    assertNull(e3);

    Map.Entry e4 = map.lowerEntry(zero);
    assertNull(e4);
}
 
源代码4 项目: j2objc   文件: TreeSubMapTest.java
/**
 * lowerEntry returns preceding entry.
 */
public void testLowerEntry() {
    NavigableMap map = map5();
    Map.Entry e1 = map.lowerEntry(three);
    assertEquals(two, e1.getKey());

    Map.Entry e2 = map.lowerEntry(six);
    assertEquals(five, e2.getKey());

    Map.Entry e3 = map.lowerEntry(one);
    assertNull(e3);

    Map.Entry e4 = map.lowerEntry(zero);
    assertNull(e4);
}
 
源代码5 项目: j2objc   文件: TreeSubMapTest.java
/**
 * lowerEntry returns preceding entry.
 */
public void testDescendingLowerEntry() {
    NavigableMap map = dmap5();
    Map.Entry e1 = map.lowerEntry(m3);
    assertEquals(m2, e1.getKey());

    Map.Entry e2 = map.lowerEntry(m6);
    assertEquals(m5, e2.getKey());

    Map.Entry e3 = map.lowerEntry(m1);
    assertNull(e3);

    Map.Entry e4 = map.lowerEntry(zero);
    assertNull(e4);
}
 
源代码6 项目: kogito-runtimes   文件: KieRepositoryImpl.java
synchronized KieModule load(InternalKieScanner kieScanner, ReleaseId releaseId, VersionRange versionRange) {
    String ga = releaseId.getGroupId() + ":" + releaseId.getArtifactId();

    NavigableMap<ComparableVersion, KieModule> artifactMap = kieModules.get(ga);
    if ( artifactMap == null || artifactMap.isEmpty() ) {
        return null;
    }
    KieModule kieModule = artifactMap.get(new ComparableVersion(releaseId.getVersion()));

    if (versionRange.fixed) {
        if ( kieModule != null && releaseId.isSnapshot() ) {
            String oldSnapshotVersion = ((ReleaseIdImpl)kieModule.getReleaseId()).getSnapshotVersion();
            if ( oldSnapshotVersion != null ) {
                String currentSnapshotVersion = kieScanner.getArtifactVersion(releaseId);
                if (currentSnapshotVersion != null &&
                    new ComparableVersion(currentSnapshotVersion).compareTo(new ComparableVersion(oldSnapshotVersion)) > 0) {
                    // if the snapshot currently available on the maven repo is newer than the cached one
                    // return null to enforce the building of this newer version
                    return null;
                }
            }
        }
        return kieModule;
    }

    Map.Entry<ComparableVersion, KieModule> entry =
            versionRange.upperBound == null ?
            artifactMap.lastEntry() :
            versionRange.upperInclusive ?
                artifactMap.floorEntry(new ComparableVersion(versionRange.upperBound)) :
                artifactMap.lowerEntry(new ComparableVersion(versionRange.upperBound));

    if ( entry == null ) {
        return null;
    }

    if ( versionRange.lowerBound == null ) {
        return entry.getValue();
    }

    int comparison = entry.getKey().compareTo(new ComparableVersion(versionRange.lowerBound));
    return comparison > 0 || (comparison == 0 && versionRange.lowerInclusive) ? entry.getValue() : null;
}