@Override
    public ConvertedRecords<? extends Records> downConvert(byte toMagic, long firstOffset, Time time) {
        ConvertedRecords<MemoryRecords> convertedRecords = RecordsUtil.downConvert(batches, toMagic, firstOffset, time);
        if (convertedRecords.recordConversionStats().numRecordsConverted() == 0) {
            // This indicates that the message is too large, which means that the buffer is not large
            // enough to hold a full record batch. We just return all the bytes in this instance.
            // Even though the record batch does not have the right format version, we expect old clients
            // to raise an error to the user after reading the record batch size and seeing that there
            // are not enough available bytes in the response to read it fully. Note that this is
            // only possible prior to KIP-74, after which the broker was changed to always return at least
            // one full record batch, even if it requires exceeding the max fetch size requested by the client.
            return new ConvertedRecords<>(this, RecordValidationStats.EMPTY);
        } else {
            return convertedRecords;
        }
    }
Truncate this file message set to the given size in bytes. Note that this API does no checking that the
given size falls on a valid message boundary.
In some versions of the JDK truncating to the same size as the file message set will cause an
update of the files mtime, so truncate is only performed if the targetSize is smaller than the
size of the underlying FileChannel.
It is expected that no other threads will do writes to the log when this function is called.
@param targetSize The size to truncate to. Must be between 0 and sizeInBytes.
@return The number of bytes truncated off
clients/src/main/java/org/apache/kafka/common/record/FileRecords.java