void updateBeforeAndAfterCompactionIndexSegmentOffsets(long compactionStartTime, Map<Offset, Offset> offsets,
      boolean fromInProgressCompaction) {
    if (offsets.size() == 0) {
      return;
    }
    if (fromInProgressCompaction) {
      // Sanity checking
      for (Offset before : offsets.keySet()) {
        if (validIndexSegments.get(before) == null) {
          String message =
              String.format("Index %s: Before offset %s is missing from the index segment map", dataDir, before);
          throw new IllegalStateException(message);
        }
      }
    }
    compactionTimestampToIndexSegmentOffsets.computeIfAbsent(compactionStartTime, k -> new HashSet<>())
        .addAll(offsets.keySet());
    beforeAndAfterCompactionIndexSegmentOffsets.putAll(offsets);
    long now = time.milliseconds();
    long cutoffTime = now - Duration.ofDays(config.storeCompactionHistoryInDay).toMillis();
    // Any compaction history before this cutoff timestamp would be removed
    // compactionTimestampToIndexSegmentOffsets is a tree map order by time
    Iterator<Map.Entry<Long, Set<Offset>>> iterator = compactionTimestampToIndexSegmentOffsets.entrySet().iterator();
    while (iterator.hasNext()) {
      Map.Entry<Long, Set<Offset>> entry = iterator.next();
      if (entry.getKey() > cutoffTime) {
        break;
      }
      Set<Offset> offsetsToRemove = entry.getValue();
      beforeAndAfterCompactionIndexSegmentOffsets.keySet().removeAll(offsetsToRemove);
      iterator.remove();
    }
  }
Update the before and after compaction index segment offsets.
@param compactionStartTime The compaction start time in milliseconds.
@param offsets The map from index segment offsets before compaction to index segment offsets after compaction.
@param fromInProgressCompaction True if this update is from an in progress compaction.
ambry-store/src/main/java/com/github/ambry/store/PersistentIndex.java