rdblue commented on a change in pull request #74: Add snapshot summary and
operation.
URL: https://github.com/apache/incubator-iceberg/pull/74#discussion_r253946229
##########
File path: core/src/main/java/com/netflix/iceberg/SnapshotUpdate.java
##########
@@ -102,6 +104,58 @@ protected SnapshotUpdate(TableOperations ops) {
*/
protected abstract void cleanUncommitted(Set<ManifestFile> committed);
+ /**
+ * A string that describes the action that produced the new snapshot.
+ *
+ * @return a string operation
+ */
+ protected abstract String operation();
+
+ /**
+ * A string map with a summary of the changes in this snapshot update.
+ *
+ * @return a string map that summarizes the update
+ */
+ protected Map<String, String> summary() {
+ return ImmutableMap.of();
+ }
+
+ /**
+ * Returns the snapshot summary from the implementation and updates totals.
+ */
+ private Map<String, String> summary(TableMetadata base) {
+ Map<String, String> summary = summary();
+ if (summary == null) {
+ return ImmutableMap.of();
+ }
+
+ Map<String, String> previousSummary;
+ if (base.currentSnapshot() != null) {
+ if (base.currentSnapshot().summary() != null) {
+ previousSummary = base.currentSnapshot().summary();
+ } else {
+ // previous snapshot had no summary, use an empty summary
+ previousSummary = ImmutableMap.of();
+ }
+ } else {
+ // if there was no previous snapshot, default the summary to start
totals at 0
+ previousSummary = ImmutableMap.of(
Review comment:
Yeah, we could make this a constant, but I like that this is more readable
having the initialization done in the same place as the updates.
We can't add the default to `updateTotal` because these totals can't be
initialized unless there is no previous snapshot. That's the case that
indicates that the total number of files and records is 0. If there a previous
snapshot, then we have to use it's totals or not produce totals.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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]