RussellSpitzer commented on code in PR #18252:
URL: https://github.com/apache/iceberg/pull/18252#discussion_r4382441650


##########
api/src/main/java/org/apache/iceberg/types/TypeUtil.java:
##########
@@ -639,11 +659,47 @@ private static int estimateSize(Type type) {
   /** Interface for passing a function that assigns column IDs. */
   public interface NextID {
     int get();
+
+    default int get(int numReserved) {
+      int id = get();
+      for (int offset = 1; offset <= numReserved; offset += 1) {
+        int reserved = get();
+        Preconditions.checkState(
+            reserved == id + offset,
+            "Failed to assign consecutive IDs %s-%s, requested %s and got %s",
+            id + 1,
+            id + numReserved,
+            id + offset,
+            reserved);
+      }
+
+      return id;
+    }
   }
 
   /** Interface for passing a function that assigns column IDs from the 
previous Id. */
   public interface GetID {
     int get(int oldId);
+
+    /**
+     * Assigns a new ID and reserves the IDs that immediately follow it.
+     *
+     * <p>Implementations must override this method to assign IDs for types 
with derived field IDs.
+     *
+     * @param oldId an existing field ID
+     * @param numReserved number of IDs after the new ID that must not be 
assigned
+     * @return a new field ID
+     */
+    default int get(int oldId, int numReserved) {

Review Comment:
   Same answer as above - 
   
   Yep, I intentionally broke the original PR into what I hoped were 
self-contained chunks. Part 2 (of 8) handles reserving the derived ID block: it 
adds the base ID validation in `Schema` and forwards `get(oldId, numReserved)` 
through the `reassignIds` wrapper, with tests for both cases.
   
   In this PR a file column can't leave the API module: `SchemaParser` doesn't 
know the type until part 3, so no table metadata can contain one yet.



-- 
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]

Reply via email to