@Override
    public void close(boolean complete) {
        if (records == null) return;
        try {
            if (complete) {
                if (!records.isEmpty()) {
                    snapshotWriter.append(records);
                }
                frozenSize = OptionalLong.of(snapshotWriter.freeze());
            }
        } finally {
            records = null;
            snapshotWriter.close();
        }
    }
Writes out a metadata image to a SnapshotWriter.
metadata/src/main/java/org/apache/kafka/image/writer/RaftSnapshotWriter.java