code: @Override
    public void flush() throws IOException {
  
      // Do not do anything if no data has been written
      if (currentDataSegmentBuffer.size() == 0) {
        return;
      }
  
      // Create the current DataSegment
      DataSegmentWriter currentDataSegment =
          new DataSegmentWriter(currentDataSegmentBuffer, codec, codecCompressor);
  
      // Update the metadata
      updateMetadata(currentDataSegmentBuffer.size(), currentDataSegment.size());
  
      // Write out the DataSegment
      currentDataSegment.writeTo(dataSegmentDataOut);
  
      // Clear out the current buffer. Note that this has to be done after
      // currentDataSegment.writeTo(...), because currentDataSegment can
      // keep a reference to the currentDataSegmentBuffer.
      currentDataSegmentBuffer.reset();
  
      // Flush out the underlying stream
      dataSegmentDataOut.flush();
    }
docs: Take the current data segment, optionally compress it,
  calculate the crc32, and then write it out.
  
  The method sets the lastOffsets to the end of the file before it starts
  writing.  That means the offsets in the MetaDataBlock will be after the
  end of the current data block.