code: private List<Segment> getCompactableSegments(SegmentManager manager) {
      List<Segment> segments = new ArrayList<>(manager.segments().size());
      Iterator<Segment> iterator = manager.segments().iterator();
      Segment segment = iterator.next();
      while (iterator.hasNext()) {
        Segment nextSegment = iterator.next();
  
        // Segments that have already been compacted are eligible for compaction. For uncompacted segments, the segment must be full, consist
        // of entries less than the minorIndex, and a later segment with at least one committed entry must exist in the log. This ensures that
        // a non-empty entry always remains at the end of the log.
        if (segment.isCompacted() || (segment.isFull() && segment.lastIndex() < compactor.minorIndex() && nextSegment.firstIndex() <= manager.commitIndex() && !nextSegment.isEmpty())) {
          segments.add(segment);
        } else {
          break;
        }
  
        segment = nextSegment;
      }
      return segments;
    }
docs: Returns a list of compactable log segments.
  
  @param manager The segment manager.
  @return A list of compactable log segments.