public int validBytes() {
        if (validBytes >= 0)
            return validBytes;

        int bytes = 0;
        for (RecordBatch batch : batches())
            bytes += batch.sizeInBytes();

        this.validBytes = bytes;
        return bytes;
    }
The total number of bytes in this message set not including any partial, trailing messages. This
may be smaller than what is returned by {@link #sizeInBytes()}.
@return The number of valid bytes
clients/src/main/java/org/apache/kafka/common/record/MemoryRecords.java