@Override
        public void write(int b) {
            throw new IllegalStateException("MemoryRecordsBuilder is closed for record appends");
        }
This class is used to write new log data in memory, i.e. this is the write path for {@link MemoryRecords}.
It transparently handles compression and exposes methods for appending new records, possibly with message
format conversion.

In cases where keeping memory retention low is important and there's a gap between the time that record appends stop
and the builder is closed (e.g. the Producer), it's important to call `closeForRecordAppends` when the former happens.
This will release resources like compression buffers that can be relatively large (64 KB for LZ4).
clients/src/main/java/org/apache/kafka/common/record/MemoryRecordsBuilder.java