fbocse commented on a change in pull request #74: Add snapshot summary and
operation.
URL: https://github.com/apache/incubator-iceberg/pull/74#discussion_r253769627
##########
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:
It's a nitpick but would you consider not having to do the initialization of
these expected properties ahead of time? It feels like we need to consider
which properties we're going to update so we can carefully craft their
initialization in this else block first.
I'd consider increasing the arity of `updateTotal` and support a default
value for each of the properties we'd invoke the method for and that default
value gets used in case that the property is missing from the previous snapshot
summary.
----------------------------------------------------------------
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]