public static LegacyRecord create(byte magic,
                                      long timestamp,
                                      byte[] key,
                                      byte[] value,
                                      CompressionType compressionType,
                                      TimestampType timestampType) {
        int keySize = key == null ? 0 : key.length;
        int valueSize = value == null ? 0 : value.length;
        ByteBuffer buffer = ByteBuffer.allocate(recordSize(magic, keySize, valueSize));
        write(buffer, magic, timestamp, wrapNullable(key), wrapNullable(value), compressionType, timestampType);
        buffer.rewind();
        return new LegacyRecord(buffer);
    }
Create a new record instance. If the record's compression type is not none, then
its value payload should be already compressed with the specified type; the constructor
would always write the value payload as is and will not do the compression itself.

@param magic The magic value to use
@param timestamp The timestamp of the record
@param key The key of the record (null, if none)
@param value The record value
@param compressionType The compression type used on the contents of the record (if any)
@param timestampType The timestamp type to be used for this record
clients/src/main/java/org/apache/kafka/common/record/LegacyRecord.java