gaborkaszab commented on code in PR #16689:
URL: https://github.com/apache/iceberg/pull/16689#discussion_r3389605994
##########
core/src/main/java/org/apache/iceberg/TrackingBuilder.java:
##########
@@ -99,35 +98,54 @@ private TrackingBuilder(Tracking source, long
newSnapshotId) {
this.replacedPositions = null;
}
- /** Indicates that the DV has been updated for the new Tracking. */
+ /**
+ * Records that the file's DV was updated by this commit, advancing {@code
dvSnapshotId} to the
+ * commit snapshot. An EXISTING entry transitions to MODIFIED; an ADDED
entry stays ADDED (a file
+ * added and given a DV in the same commit).
+ */
TrackingBuilder dvUpdated() {
- // DV applies to data files; deleted/replaced positions apply to manifest
files
Preconditions.checkState(
deletedPositions == null && replacedPositions == null,
"Cannot mark DV updated on a manifest entry (deleted/replaced
positions are set)");
this.dvSnapshotId = newSnapshotId;
+ if (status == EntryStatus.EXISTING) {
+ this.status = EntryStatus.MODIFIED;
+ }
+
return this;
}
+ /**
+ * Records the manifest-leaf positions deleted by this commit, advancing
{@code dvSnapshotId} to
+ * the commit snapshot and transitioning an EXISTING entry to MODIFIED.
Cannot be called on an
+ * ADDED entry.
+ */
TrackingBuilder deletedPositions(ByteBuffer positions) {
Preconditions.checkState(
- status == EntryStatus.EXISTING, "Cannot set deleted positions on %s
entry", status);
- // DV applies to data files; deleted positions apply to manifest files
- Preconditions.checkState(
- dvSnapshotId == null,
- "Cannot set deleted positions on a data file entry (DV snapshot ID is
set)");
+ status != EntryStatus.ADDED, "Cannot set deleted positions on ADDED
entry");
this.deletedPositions = ByteBuffers.toByteArray(positions);
+ this.dvSnapshotId = newSnapshotId;
+ if (status == EntryStatus.EXISTING) {
Review Comment:
If introducing new statuses in the future, we have to re-visit this check
anyway to decide whether it should pass or not the check.
Anyway, no strong feelings here. If everyone is fine with this, I'm too.
--
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]