public int keySize() {
        if (magic() == RecordBatch.MAGIC_VALUE_V0)
            return buffer.getInt(KEY_SIZE_OFFSET_V0);
        else
            return buffer.getInt(KEY_SIZE_OFFSET_V1);
    }
The length of the key in bytes
@return the size in bytes of the key (0 if the key is null)
clients/src/main/java/org/apache/kafka/common/record/LegacyRecord.java