byte[] toBytes() {
    /*
      Description of format

      version
      referenceTimeMs
      isFullRange (only in version 1)
      size of the logSegmentsUnderCompaction list
      segment_1_name_length segment_1_name
      segment_2_name_length segment_2_name
      ....
     */

    List<byte[]> segmentNameBytesList = new ArrayList<>();
    int size =
        VERSION_SIZE + REFERENCE_TIME_SIZE + SEGMENT_COUNT_SIZE + (CURRENT_VERSION == VERSION_1 ? IS_FULL_RANGE_SIZE
            : 0);
    for (LogSegmentName segmentName : logSegmentsUnderCompaction) {
      byte[] segmentNameBytes = segmentName.toString().getBytes();
      segmentNameBytesList.add(segmentNameBytes);
      size += SEGMENT_NAME_LENGTH_SIZE + segmentNameBytes.length;
    }

    byte[] buf = new byte[size];
    ByteBuffer bufWrap = ByteBuffer.wrap(buf);
    // version
    bufWrap.putShort(CURRENT_VERSION);
    // reference time
    bufWrap.putLong(referenceTimeMs);
    if (CURRENT_VERSION == VERSION_1) {
      bufWrap.put(isFullRange ? (byte) 1 : (byte) 0);
    }
    // size of logSegmentsUnderCompaction
    bufWrap.putInt(logSegmentsUnderCompaction.size());
    // log segments under compaction
    for (byte[] segmentNameBytes : segmentNameBytesList) {
      bufWrap.putInt(segmentNameBytes.length);
      bufWrap.put(segmentNameBytes);
    }
    return buf;
  }
@return serialized representation of this object.
ambry-store/src/main/java/com/github/ambry/store/CompactionDetails.java