rdblue commented on code in PR #19030:
URL: https://github.com/apache/iceberg/pull/19030#discussion_r4636931676
##########
core/src/main/java/org/apache/iceberg/SnapshotProducer.java:
##########
@@ -286,25 +289,42 @@ public ThisT deleteWith(Consumer<String> deleteCallback) {
protected void validate(TableMetadata currentMetadata, Snapshot snapshot) {}
/**
- * Apply the update's changes to the given metadata and snapshot. Return the
new manifest list.
+ * Apply the update's changes to the given metadata and snapshot. Return the
new version's
+ * manifests as a list.
*
* @param metadataToUpdate the base table metadata to apply changes to
- * @param snapshot snapshot to apply the changes to
+ * @param snapshot snapshot to apply the changes to; will be the new
snapshot's parent
* @return a manifest list for the new snapshot.
*/
protected abstract List<ManifestFile> apply(TableMetadata metadataToUpdate,
Snapshot snapshot);
- @Override
- public Snapshot apply() {
- refresh();
- Snapshot parentSnapshot = SnapshotUtil.latestSnapshot(base, targetBranch);
-
- long sequenceNumber = base.nextSequenceNumber();
- Long parentSnapshotId = parentSnapshot == null ? null :
parentSnapshot.snapshotId();
+ /** Result type for root file writes implemented by child operations. */
+ protected record NewSnapshotMetadata(
+ String manifestListLocation,
+ String rootManifestLocation,
+ long rootFileSize,
+ Long assignedRowIds,
+ Set<String> manifestLocations) {
+ private String rootLocation() {
+ return manifestListLocation != null ? manifestListLocation :
rootManifestLocation;
+ }
+ }
- runValidations(parentSnapshot);
+ /**
+ * Apply the update's change to the given metadata and snapshot. Return the
new root manifest
+ * metadata.
+ *
+ * @param metadataToUpdate the base table metadata to apply changes to
+ * @param parent snapshot to apply the changes to; will be the new
snapshot's parent
+ * @return a {@link TrackedFile} for the new root manifest
+ */
+ protected NewSnapshotMetadata writeRootManifest(
+ TableMetadata metadataToUpdate, Snapshot parent, long sequenceNumber) {
+ throw new UnsupportedOperationException("v4 writes are not yet
implemented");
+ }
- List<ManifestFile> manifests = apply(base, parentSnapshot);
+ protected NewSnapshotMetadata writeManifestList(Snapshot parent, long
sequenceNumber) {
Review Comment:
This method was factored out of `apply()` and is responsible for writing a
v1-v3 manifest list, then returning the metadata for it to build a new snapshot.
This is directly equivalent to the `writeRootManifest` method that is used
for v4, but that one has to be implemented by `MergingSnapshotProducer`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]