Esempio n. 1
0
 @CollectionSize.Require(SEVERAL)
 public void testCeiling() {
   resetWithHole();
   assertEquals(a, navigableMap.ceilingEntry(a.getKey()));
   assertEquals(a.getKey(), navigableMap.ceilingKey(a.getKey()));
   assertEquals(c, navigableMap.ceilingEntry(b.getKey()));
   assertEquals(c.getKey(), navigableMap.ceilingKey(b.getKey()));
   assertEquals(c, navigableMap.ceilingEntry(c.getKey()));
   assertEquals(c.getKey(), navigableMap.ceilingKey(c.getKey()));
 }
Esempio n. 2
0
 @CollectionSize.Require(ZERO)
 public void testEmptyMapNearby() {
   assertNull(navigableMap.lowerEntry(samples.e0.getKey()));
   assertNull(navigableMap.lowerKey(samples.e0.getKey()));
   assertNull(navigableMap.floorEntry(samples.e0.getKey()));
   assertNull(navigableMap.floorKey(samples.e0.getKey()));
   assertNull(navigableMap.ceilingEntry(samples.e0.getKey()));
   assertNull(navigableMap.ceilingKey(samples.e0.getKey()));
   assertNull(navigableMap.higherEntry(samples.e0.getKey()));
   assertNull(navigableMap.higherKey(samples.e0.getKey()));
 }
Esempio n. 3
0
 @CollectionSize.Require(ONE)
 public void testSingletonMapNearby() {
   assertNull(navigableMap.lowerEntry(samples.e0.getKey()));
   assertNull(navigableMap.lowerKey(samples.e0.getKey()));
   assertEquals(a, navigableMap.floorEntry(samples.e0.getKey()));
   assertEquals(a.getKey(), navigableMap.floorKey(samples.e0.getKey()));
   assertEquals(a, navigableMap.ceilingEntry(samples.e0.getKey()));
   assertEquals(a.getKey(), navigableMap.ceilingKey(samples.e0.getKey()));
   assertNull(navigableMap.higherEntry(samples.e0.getKey()));
   assertNull(navigableMap.higherKey(samples.e0.getKey()));
 }
 private Key findBestKey(int size, Bitmap.Config config) {
   Key result = keyPool.get(size, config);
   for (Bitmap.Config possibleConfig : getInConfigs(config)) {
     NavigableMap<Integer, Integer> sizesForPossibleConfig = getSizesForConfig(possibleConfig);
     Integer possibleSize = sizesForPossibleConfig.ceilingKey(size);
     if (possibleSize != null && possibleSize <= size * MAX_SIZE_MULTIPLE) {
       if (possibleSize != size
           || (possibleConfig == null ? config != null : !possibleConfig.equals(config))) {
         keyPool.offer(result);
         result = keyPool.get(possibleSize, possibleConfig);
       }
       break;
     }
   }
   return result;
 }
Esempio n. 5
0
  /**
   * lowInclusive and highInclusive are ignored if the respective bound in null (unbounded).
   *
   * @param low
   * @param lowInclusive
   * @param high
   * @param highInclusive
   * @return
   */
  public RangeApacheLogEntryIterator getIterator(
      Date low, Date high, boolean lowInclusive, boolean highInclusive) {
    NavigableMap<Date, File> subMap = dateToFile;

    Date adjustedLow = low == null ? null : dateToFile.floorKey(low);
    Date adjustedHigh = high == null ? null : dateToFile.ceilingKey(high);

    // lower bound
    if (adjustedLow != null) {
      subMap = subMap.tailMap(adjustedLow, true);
    }

    // upperbound
    if (adjustedHigh != null) {
      subMap = subMap.headMap(adjustedHigh, true);
    }

    logger.debug(
        "Adjust: Creating an iterator from "
            + adjustedLow
            + " until "
            + adjustedHigh
            + "; spanning "
            + subMap.size()
            + " files.");
    logger.debug(
        "Creating an iterator from "
            + low
            + " until "
            + high
            + "; spanning "
            + subMap.size()
            + " files.");

    return new RangeApacheLogEntryIterator(
        subMap.entrySet().iterator(), low, lowInclusive, high, highInclusive);
  }