public int append(MemoryRecords records) throws IOException {
        if (records.sizeInBytes() > Integer.MAX_VALUE - size.get())
            throw new IllegalArgumentException("Append of size " + records.sizeInBytes() +
                    " bytes is too large for segment with current file position at " + size.get());

        int written = records.writeFullyTo(channel);
        size.getAndAdd(written);
        return written;
    }
Append a set of records to the file. This method is not thread-safe and must be
protected with a lock.

@param records The records to append
@return the number of bytes written to the underlying file
clients/src/main/java/org/apache/kafka/common/record/FileRecords.java