jackye1995 commented on a change in pull request #3104:
URL: https://github.com/apache/iceberg/pull/3104#discussion_r782441368
##########
File path: core/src/main/java/org/apache/iceberg/TableMetadata.java
##########
@@ -725,6 +764,49 @@ private static SortOrder freshSortOrder(int orderId,
Schema schema, SortOrder so
return builder.build();
}
+ private Map<String, SnapshotRef> validateAndCompleteRefs(Map<String,
SnapshotRef> inputRefs) {
+ for (SnapshotRef ref : inputRefs.values()) {
+ Preconditions.checkArgument(snapshotsById.containsKey(ref.snapshotId())
|| ref.snapshotId() == -1,
+ "Snapshot reference %s does not exist in the existing snapshots
list", ref);
+ }
+
+ if (!inputRefs.containsKey(SnapshotRef.MAIN_BRANCH)) {
+ return refsWithMainBranch(currentSnapshotId, inputRefs);
+ }
+
+ return inputRefs;
+ }
+
+ private SetMultimap<Long, SnapshotRef> indexRefs() {
+ ImmutableSetMultimap.Builder<Long, SnapshotRef> builder =
ImmutableSetMultimap.builder();
+ for (SnapshotRef ref : refs.values()) {
+ builder.put(ref.snapshotId(), ref);
+ }
+
+ return builder.build();
+ }
+
+ /**
+ * Get a new list of refs with the main branch head pointing to the given
snapshot ID
+ *
+ * @param snapshotId snapshot ID of the main branch head
+ * @param currentRefs current table refs list
+ * @return updated refs list
+ */
+ private static Map<String, SnapshotRef> refsWithMainBranch(long snapshotId,
Map<String, SnapshotRef> currentRefs) {
Review comment:
Yes +1 for creating an empty snapshot when creating a table
--
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]