private byte[] encodeData(final byte[] data) {
        ByteBuffer buffer = ByteBuffer.allocate(getWriteBytes(data));
        buffer.put(RECORD_MAGIC_BYTES);
        buffer.putInt(data.length);
        buffer.put(data);
        buffer.flip();
        return buffer.array();
    }
Write the data and return it's wrote position.
@param logIndex the log index
@param data     data to write
@return the wrote position
jraft-extension/java-log-storage-impl/src/main/java/com/alipay/sofa/jraft/storage/file/segment/SegmentFile.java