RussellSpitzer commented on code in PR #18252:
URL: https://github.com/apache/iceberg/pull/18252#discussion_r4557255462
##########
api/src/main/java/org/apache/iceberg/types/TypeUtil.java:
##########
@@ -639,11 +667,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) {
+ if (numReserved > 0) {
+ throw new UnsupportedOperationException(
+ String.format(
+ "Cannot reserve %s IDs for field %s: reserving IDs is not
supported",
Review Comment:
Fixed, Now since it's type based it just says the type
--
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]