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


##########
core/src/main/java/org/apache/iceberg/StatsUtil.java:
##########
@@ -19,171 +19,291 @@
 package org.apache.iceberg;
 
 import static org.apache.iceberg.types.Types.NestedField.optional;
+import static org.apache.iceberg.types.Types.NestedField.required;
 
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-import java.util.stream.Collectors;
-import org.apache.iceberg.relocated.com.google.common.collect.ImmutableSet;
+import java.util.Map;
+import 
org.apache.iceberg.relocated.com.google.common.annotations.VisibleForTesting;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
-import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.apache.iceberg.types.Type;
 import org.apache.iceberg.types.TypeUtil;
 import org.apache.iceberg.types.Types;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 class StatsUtil {
-  private static final Logger LOG = LoggerFactory.getLogger(StatsUtil.class);
-  static final Set<Integer> SUPPORTED_METADATA_FIELD_IDS =
-      ImmutableSet.of(
-          MetadataColumns.LAST_UPDATED_SEQUENCE_NUMBER.fieldId(), 
MetadataColumns.ROW_ID.fieldId());
-  private static final int FIRST_SUPPORTED_METADATA_FIELD_ID =
-      Collections.min(SUPPORTED_METADATA_FIELD_IDS);
-  static final int NUM_SUPPORTED_STATS_PER_COLUMN = 200;
-  static final int STATS_SPACE_FIELD_ID_START_FOR_METADATA_FIELDS = 9_000;
-  static final int STATS_SPACE_FIELD_ID_START_FOR_DATA_FIELDS = 10_000;
-  // exclusive upper bound of the stats field ID range reserved for 
content_stats
-  static final int STATS_SPACE_FIELD_ID_END = 200_000_000;
-  static final int MAX_DATA_STATS_FIELD_ID =
-      STATS_SPACE_FIELD_ID_END - NUM_SUPPORTED_STATS_PER_COLUMN;
-  // the max data field ID whose stats struct fits within the reserved range
-  static final int MAX_DATA_FIELD_ID =
-      (MAX_DATA_STATS_FIELD_ID - STATS_SPACE_FIELD_ID_START_FOR_DATA_FIELDS)
-          / NUM_SUPPORTED_STATS_PER_COLUMN;
-
   private StatsUtil() {}
 
-  public static int statsFieldIdForField(int fieldId) {
-    return SUPPORTED_METADATA_FIELD_IDS.contains(fieldId)
-        ? statsFieldIdForReservedField(fieldId)
-        : statsFieldIdForDataField(fieldId);
-  }
+  private static final int NUM_RESERVED_FIELD_STATS_IDS = 200;
+  private static final int METADATA_STATS_RANGE_START = 9_000;
+  private static final int CONTENT_STATS_RANGE_START = 10_000;
+  private static final int CONTENT_STATS_RANGE_END = 200_000_000; // exclusive
+
+  private static final int DATA_FIELD_ID_START = 0;
+  private static final int DATA_FIELD_ID_END = 999_950; // exclusive

Review Comment:
   Added a comment to clarify. I don't think the calculation adds much. I 
stated that this corresponds to stats base ID 200_000_000 that is the end of 
the stats range.



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