public List<KRFEntry> getSortedLiveEntries(Collection<DiskRegionInfo> targetRegions) {
    int tlc = (int) totalLiveCount.get();
    if (tlc <= 0) {
      // no need to create a KRF since this oplog will be deleted.
      // TODO should we create an empty KRF anyway?
      return null;
    }

    KRFEntry[] sortedLiveEntries = new KRFEntry[tlc];
    int idx = 0;
    for (DiskRegionInfo dri : targetRegions) {
      if (dri.getDiskRegion() != null) {
        idx = dri.addLiveEntriesToList(sortedLiveEntries, idx);
      }
    }
    // idx is now the length of sortedLiveEntries
    Arrays.sort(sortedLiveEntries, 0, idx, (o1, o2) -> {
      long val1 = o1.getOffsetInOplogForSorting();
      long val2 = o2.getOffsetInOplogForSorting();
      return Long.signum(val1 - val2);
    });

    return Arrays.asList(sortedLiveEntries).subList(0, idx);
  }
Create the KRF file for this oplog. It is ok for this method to be async. finishKRF will be
called and it must block until KRF generation is complete.

@param cancel if true then prevent the krf from being created if possible
geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java