rdblue commented on a change in pull request #695: [WIP] Cherrypick snapshot
feature
URL: https://github.com/apache/incubator-iceberg/pull/695#discussion_r364397559
##########
File path: core/src/main/java/org/apache/iceberg/TableMetadata.java
##########
@@ -391,17 +401,34 @@ public TableMetadata addStagedSnapshot(Snapshot
snapshot) {
}
public TableMetadata replaceCurrentSnapshot(Snapshot snapshot) {
- List<Snapshot> newSnapshots = ImmutableList.<Snapshot>builder()
- .addAll(snapshots)
- .add(snapshot)
- .build();
- List<HistoryEntry> newSnapshotLog = ImmutableList.<HistoryEntry>builder()
- .addAll(snapshotLog)
- .add(new SnapshotLogEntry(snapshot.timestampMillis(),
snapshot.snapshotId()))
- .build();
- return new TableMetadata(null, uuid, location,
- snapshot.timestampMillis(), lastColumnId, schema, defaultSpecId,
specs, properties,
- snapshot.snapshotId(), newSnapshots, newSnapshotLog,
addPreviousFile(file, lastUpdatedMillis));
+ // there can be operations (viz. rollback, cherrypick) where an existing
snapshot could be replacing current
Review comment:
This method isn't used for rollback; that calls `rollbackTo`. I think it
would be easier to update `rollbackTo` to be `setCurrentSnapshotTo`. Then
cherrypick should use either `replaceCurrentSnapshot` if it is creating a new
snapshot, or `setCurrentSnapshotTo` if it is using an existing snapshot (the
fast-forward case).
The reason I'd structure it this way is to keep the methods in this file
independent of the operations that they are used for. That way
`replaceCurrentSnapshot` doesn't care how it is called and always does the same
thing: adds a snapshot, updates the current pointer, and updates the snapshot
log. Similarly, `setCurrentSnapshotTo` will have simple behavior.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]