@Override
  public Snapshot apply() {
    refresh();
    Snapshot parentSnapshot = SnapshotUtil.latestSnapshot(base, targetBranch);

    long sequenceNumber = base.nextSequenceNumber();
    Long parentSnapshotId = parentSnapshot == null ? null : parentSnapshot.snapshotId();

    validate(base, parentSnapshot);
    List<ManifestFile> manifests = apply(base, parentSnapshot);

    OutputFile manifestList = manifestListPath();

    try (ManifestListWriter writer =
             ManifestLists.write(
                 ops.current().formatVersion(),
                 manifestList,
                 snapshotId(),
                 parentSnapshotId,
                 sequenceNumber)) {

      // keep track of the manifest lists created
      manifestLists.add(manifestList.location());

      ManifestFile[] manifestFiles = new ManifestFile[manifests.size()];

      Tasks.range(manifestFiles.length)
          .stopOnFailure()
          .throwFailureWhenFinished()
          .executeWith(workerPool())
          .run(index -> manifestFiles[index] = manifestsWithMetadata.get(manifests.get(index)));

      writer.addAll(Arrays.asList(manifestFiles));
    } catch (IOException e) {
      throw new RuntimeIOException(e, "Failed to write manifest list file");
    }

    return new BaseSnapshot(
        sequenceNumber,
        snapshotId(),
        parentSnapshotId,
        System.currentTimeMillis(),
        operation(),
        summary(base),
        base.currentSchemaId(),
        manifestList.location());
  }
Apply the update's changes to the given metadata and snapshot. Return the new manifest list.

@param metadataToUpdate the base table metadata to apply changes to
@param snapshot snapshot to apply the changes to
@return a manifest list for the new snapshot.
iceberg/patched-iceberg-core/src/main/java/org/apache/iceberg/SnapshotProducer.java