public static BatchFileWriter open(Path snapshotPath) throws IOException {
        Time time = Time.SYSTEM;
        BatchAccumulator<ApiMessageAndVersion> batchAccumulator = new BatchAccumulator<>(
            0,
            0,
            Integer.MAX_VALUE,
            MAX_BATCH_SIZE_BYTES,
            new BatchMemoryPool(5, MAX_BATCH_SIZE_BYTES),
            time,
            Compression.NONE,
            new MetadataRecordSerde()
        );

        // Append the snapshot header control record and force it to create a batch
        batchAccumulator.appendSnapshotHeaderRecord(
            new SnapshotHeaderRecord()
                .setVersion(ControlRecordUtils.SNAPSHOT_HEADER_CURRENT_VERSION)
                .setLastContainedLogTimestamp(0),
            time.milliseconds()
        );
        batchAccumulator.forceDrain();

        FileChannel channel = FileChannel.open(
            snapshotPath,
            StandardOpenOption.CREATE_NEW,
            StandardOpenOption.WRITE
        );

        return new BatchFileWriter(channel, batchAccumulator, time);
    }
Write an arbitrary set of metadata records into a Kafka metadata log batch format.

This is similar to the binary format used for metadata snapshot files, but the log epoch
and initial offset are set to zero. This type includes a SnapshotHeaderRecord record in the
first batch and a SnapshotFooterRecord record in the last batch.
metadata/src/main/java/org/apache/kafka/metadata/util/BatchFileWriter.java