private DateTieredCompactionRequest generateCompactionRequest(ArrayList<HStoreFile> storeFiles,
    CompactionWindow window, boolean mayUseOffPeak, boolean mayBeStuck, int minThreshold, long now)
    throws IOException {
    // The files has to be in ascending order for ratio-based compaction to work right
    // and removeExcessFile to exclude youngest files.
    Collections.reverse(storeFiles);

    // Compact everything in the window if have more files than comConf.maxBlockingFiles
    compactionPolicyPerWindow.setMinThreshold(minThreshold);
    ArrayList<HStoreFile> storeFileSelection = mayBeStuck
      ? storeFiles
      : compactionPolicyPerWindow.applyCompactionPolicy(storeFiles, mayUseOffPeak, false);
    if (storeFileSelection != null && !storeFileSelection.isEmpty()) {
      // If there is any file in the window excluded from compaction,
      // only one file will be output from compaction.
      boolean singleOutput = storeFiles.size() != storeFileSelection.size()
        || comConf.useDateTieredSingleOutputForMinorCompaction();
      List<Long> boundaries = getCompactionBoundariesForMinor(window, singleOutput);
      // we want to generate policy to boundaries for minor compaction
      Map<Long, String> boundaryPolicyMap =
        getBoundariesStoragePolicyForMinor(singleOutput, window, now);
      DateTieredCompactionRequest result =
        new DateTieredCompactionRequest(storeFileSelection, boundaries, boundaryPolicyMap);
      return result;
    }
    return null;
  }
We receive store files sorted in ascending order by seqId then scan the list of files. If the
current file has a maxTimestamp older than last known maximum, treat this file as it carries
the last known maximum. This way both seqId and timestamp are in the same order. If files carry
the same maxTimestamps, they are ordered by seqId. We then reverse the list so they are ordered
by seqId and maxTimestamp in descending order and build the time windows. All the out-of-order
data into the same compaction windows, guaranteeing contiguous compaction based on sequence id.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/DateTieredCompactionPolicy.java