public ByteBuffer key() {
        if (magic() == RecordBatch.MAGIC_VALUE_V0)
            return Utils.sizeDelimited(buffer, KEY_SIZE_OFFSET_V0);
        else
            return Utils.sizeDelimited(buffer, KEY_SIZE_OFFSET_V1);
    }
A ByteBuffer containing the message key
@return the buffer or null if the key for this record is null
clients/src/main/java/org/apache/kafka/common/record/LegacyRecord.java