prodeezy commented on a change in pull request #695: [WIP] Cherrypick snapshot
feature
URL: https://github.com/apache/incubator-iceberg/pull/695#discussion_r364985009
##########
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:
The way i see this is, TableMetadata still doesn't need to know about
rollback or cherrypick but can handle replacing `current_snapshot` with an
existing snapshot OR a new snapshot. It's just handling both cases. viz.
```
setCurrentSnapshotTo(snapshot) {
// updates the current pointer,
// and updates the snapshot log.
}
replaceCurrentSnapshot(snapshot) {
if (exists) {
setCurrentSnapshotTo(snapshot)
} else {
// adds a snapshot,
// updates the current pointer,
// and updates the snapshot log.
}
}
```
----------------------------------------------------------------
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]