@Override
    public void write(ApiMessageAndVersion record) {
        if (records == null) throw new ImageWriterClosedException();
        records.add(record);
        if (records.size() >= batchSize) {
            snapshotWriter.append(records);
            records = new ArrayList<>();
        }
    }
Writes out a metadata image to a SnapshotWriter.
metadata/src/main/java/org/apache/kafka/image/writer/RaftSnapshotWriter.java