List<IndexEntry> getValidIndexEntriesForLogSegment(LogSegment segment, long deleteReferenceTimeMs,
      long expiryReferenceTimeMs, FileSpan fileSpanUnderCompaction, DeleteTombstoneStats.Builder builder,
      Pair<Set<MockId>, Set<MockId>> expiredDeletes, boolean invalidateExpiredDelete) {
    List<IndexEntry> validEntries = new ArrayList<>();
    Offset indexSegmentStartOffset = new Offset(segment.getName(), segment.getStartOffset());
    while (indexSegmentStartOffset != null && indexSegmentStartOffset.getName().equals(segment.getName())) {
      validEntries.addAll(
          getValidIndexEntriesForIndexSegment(indexSegmentStartOffset, deleteReferenceTimeMs, expiryReferenceTimeMs,
              fileSpanUnderCompaction, builder, expiredDeletes, invalidateExpiredDelete, null));
      indexSegmentStartOffset = referenceIndex.higherKey(indexSegmentStartOffset);
    }
    return validEntries;
  }
Gets all the valid index entries (taking into account different reference times) in the {@code segment}.
@param segment the {@link LogSegment} from which valid index entries are required.
@param deleteReferenceTimeMs the reference time in ms until which deletes are relevant.
@param expiryReferenceTimeMs the reference time in ms until which expirations are relevant
@param fileSpanUnderCompaction only useful for compaction tests to help determine whether update records will be
                               cleaned up. All other use cases should use {@code null}.
@param builder a builder that tracks stats related delete tombstones in log segments.
@param expiredDeletes a pair of two sets of deletes. The first one contains expired delete tombstones (with no
                      associated PUT); the second one includes expired deletes currently with PUTs ahead of them.
@param invalidateExpiredDelete whether to invalidate expired delete.
@return all the valid index entries in the {@code segment}.
ambry-store/src/test/java/com/github/ambry/store/CuratedLogIndexState.java