private void flushVersion1And2(DataOutputStream stream) throws IOException {
    stream.writeLong(startTime);
    if (startOffsetOfLastIndexSegmentForDeleteCheck == null) {
      stream.writeByte(0);
    } else {
      stream.writeByte(1);
      stream.write(startOffsetOfLastIndexSegmentForDeleteCheck.toBytes());
    }
    stream.writeInt(currentIdx);
    stream.writeInt(cycleLogs.size());
    for (CycleLog cycleLog : cycleLogs) {
      stream.write(cycleLog.toBytes());
    }
    if (version >= VERSION_2) {
      stream.writeInt(beforeAndAfterIndexSegmentOffsets.size());
      // BeforeAndAfterIndexSegmentOffsets is a tree map that would return offset in order
      for (Map.Entry<Offset, Offset> entry : beforeAndAfterIndexSegmentOffsets.entrySet()) {
        stream.write(entry.getKey().toBytes());
        stream.write(entry.getValue().toBytes());
      }
    }
  }
Flush the CompactionLog following the version 1 or 2 format.
Version 1:
    version
    startTime
    byte to indicate whether startOffsetOfLastIndexSegmentForDeleteCheck is present (1) or not (0)
    startOffsetOfLastIndexSegmentForDeleteCheck if not null
    index of current cycle's log
    size of cycle log list
    cycleLog1 (see CycleLog#toBytes())
    cycleLog2
    ...
    crc

Version 2:
    version
    startTime
    byte to indicate whether startOffsetOfLastIndexSegmentForDeleteCheck is present (1) or not (0)
    startOffsetOfLastIndexSegmentForDeleteCheck if not null
    index of current cycle's log
    size of cycle log list
    cycleLog1 (see CycleLog#toBytes())
    cycleLog2
    ...
    size of beforeAndAfterIndexSegmentOffsetsMap
    beforeOffset1, afterOffset1
    beforeOffset2, afterOffset2
    ...
    crc
@param stream The output stream to write bytes to
@throws IOException
ambry-store/src/main/java/com/github/ambry/store/CompactionLog.java