public static void writeCompressedRecordHeader(ByteBuffer buffer,
                                                   byte magic,
                                                   int recordSize,
                                                   long timestamp,
                                                   CompressionType compressionType,
                                                   TimestampType timestampType) {
        int recordPosition = buffer.position();
        int valueSize = recordSize - recordOverhead(magic);

        // write the record header with a null value (the key is always null for the wrapper)
        write(buffer, magic, timestamp, null, null, compressionType, timestampType);
        buffer.position(recordPosition);

        // now fill in the value size
        buffer.putInt(recordPosition + keyOffset(magic), valueSize);

        // compute and fill the crc from the beginning of the message
        long crc = crc32(buffer, MAGIC_OFFSET, recordSize - MAGIC_OFFSET);
        ByteUtils.writeUnsignedInt(buffer, recordPosition + CRC_OFFSET, crc);
    }
Write the header for a compressed record set in-place (i.e. assuming the compressed record data has already
been written at the value offset in a wrapped record). This lets you dynamically create a compressed message
set, and then go back later and fill in its size and CRC, which saves the need for copying to another buffer.

@param buffer The buffer containing the compressed record data positioned at the first offset of the
@param magic The magic value of the record set
@param recordSize The size of the record (including record overhead)
@param timestamp The timestamp of the wrapper record
@param compressionType The compression type used
@param timestampType The timestamp type of the wrapper record
clients/src/main/java/org/apache/kafka/common/record/LegacyRecord.java