rdblue commented on code in PR #13039:
URL: https://github.com/apache/iceberg/pull/13039#discussion_r2241262894


##########
core/src/main/java/org/apache/iceberg/MetricsConfig.java:
##########
@@ -107,6 +115,81 @@ public static MetricsConfig forPositionDelete(Table table) 
{
     return new MetricsConfig(columnModes.build(), defaultMode);
   }
 
+  static Iterable<Integer> breadthFirstFieldPriority(Schema schema) {
+    return TypeUtil.visit(
+        schema,
+        new TypeUtil.CustomOrderSchemaVisitor<>() {
+
+          @Override
+          public Iterable<Integer> schema(Schema schema, 
Supplier<Iterable<Integer>> structResult) {
+            return structResult.get();
+          }
+
+          @Override
+          public Iterable<Integer> struct(
+              Types.StructType struct, Iterable<Iterable<Integer>> 
fieldResults) {
+
+            List<Integer> orderedFieldIds =
+                Lists.newArrayListWithExpectedSize(struct.fields().size());
+            for (Types.NestedField field : struct.fields()) {
+              if (field.type().isPrimitiveType()) {
+                orderedFieldIds.add(field.fieldId());
+              }
+            }
+            return Iterables.concat(orderedFieldIds, 
Iterables.concat(fieldResults));
+          }
+
+          @Override
+          public Iterable<Integer> field(
+              Types.NestedField field, Supplier<Iterable<Integer>> future) {
+            return future.get();
+          }
+
+          @Override
+          public Iterable<Integer> list(Types.ListType list, 
Supplier<Iterable<Integer>> future) {
+            List<Integer> returnValue = Lists.newArrayListWithCapacity(1);
+            if (list.elementType().isPrimitiveType()) {
+              returnValue.add(list.elementId());
+            }
+            return Iterables.concat(returnValue, future.get());
+          }
+
+          @Override
+          public Iterable<Integer> map(
+              Types.MapType map,
+              Supplier<Iterable<Integer>> keyFuture,
+              Supplier<Iterable<Integer>> valueFuture) {
+            List<Integer> returnValue = Lists.newArrayListWithCapacity(2);
+            if (map.keyType().isPrimitiveType()) {
+              returnValue.add(map.keyId());
+            }
+            if (map.valueType().isPrimitiveType()) {
+              returnValue.add(map.valueId());
+            }
+
+            return Iterables.concat(returnValue, keyFuture.get(), 
valueFuture.get());
+          }
+
+          @Override
+          public Iterable<Integer> variant(Types.VariantType variant) {
+            return Collections.emptyList();
+          }
+
+          @Override
+          public Iterable<Integer> primitive(Type.PrimitiveType primitive) {
+            return Collections.emptyList();
+          }
+        });
+  }
+
+  static Schema boundedBreadthFirstSubSchema(Schema schema, int 
maxInferredDefaultColumns) {

Review Comment:
   It's good to use breadth-first priority, but I don't think that the policy 
needs to be exposed to the caller. How about renaming this something like  
`limitFields`?



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