SortedMap<Offset, Offset> getBeforeAndAfterIndexSegmentOffsetsForCompletedCycles() {
    if (beforeAndAfterIndexSegmentOffsets.size() == 0 || currentIdx >= cycleLogs.size()) {
      return beforeAndAfterIndexSegmentOffsets;
    }

    if (currentIdx == 0) {
      return new TreeMap<>();
    }

    List<CycleLog> cycles = cycleLogs.subList(0, currentIdx);
    List<LogSegmentName> completedLogSegmentNames = cycles.stream()
        .flatMap(cycleLog -> cycleLog.compactionDetails.getLogSegmentsUnderCompaction().stream())
        .collect(Collectors.toList());
    return getBeforeAndAfterIndexSegmentOffsetsForLogSegments(completedLogSegmentNames);
  }
Return index segment offset map for completed cycles. Each key offset's LogSegmentName has to finish the compaction.
ambry-store/src/main/java/com/github/ambry/store/CompactionLog.java