コード例 #1
0
ファイル: LocalJournal.java プロジェクト: hotbain/modeshape
  @Override
  public Records recordsNewerThan(
      DateTime changeSetTime, boolean inclusive, boolean descendingOrder) {
    if (stopped) {
      return Records.EMPTY;
    }

    long changeSetMillisUTC = -1;
    long searchBound = -1;
    if (changeSetTime != null) {
      changeSetMillisUTC = changeSetTime.getMillis();
      // adjust the millis using a delta so that we are sure we catch everything in a cluster which
      // may have differences in
      // clock time
      searchBound = TIME_BASED_KEYS.getCounterStartingAt(changeSetMillisUTC - searchTimeDelta);
    }

    NavigableMap<Long, JournalRecord> subMap = records.tailMap(searchBound, true);

    // process each of the records from the result and look at the timestamp of the changeset, so
    // that we're sure we only include
    // the correct ones (we used a delta to make sure we get everything)
    long startKeyInSubMap = -1;
    for (Long timeBasedKey : subMap.keySet()) {
      JournalRecord record = subMap.get(timeBasedKey);
      long recordChangeTimeMillisUTC = record.getChangeTimeMillis();
      if (((recordChangeTimeMillisUTC == changeSetMillisUTC) && inclusive)
          || recordChangeTimeMillisUTC > changeSetMillisUTC) {
        startKeyInSubMap = timeBasedKey;
        break;
      }
    }
    return startKeyInSubMap != -1
        ? recordsFrom(subMap.tailMap(startKeyInSubMap, true), descendingOrder)
        : Records.EMPTY;
  }