nastra commented on code in PR #15432:
URL: https://github.com/apache/iceberg/pull/15432#discussion_r2847657991
##########
api/src/main/java/org/apache/iceberg/stats/FieldStatistic.java:
##########
@@ -41,68 +41,75 @@ public enum FieldStatistic {
this.fieldName = fieldName;
}
+ /**
+ * The offset from the base field ID
+ *
+ * @return The offset from the base field ID
+ */
public int offset() {
return offset;
}
+ /**
+ * The field name
+ *
+ * @return The field name
+ */
public String fieldName() {
return fieldName;
}
- public static FieldStatistic fromOffset(int offset) {
- switch (offset) {
- case 0:
- return VALUE_COUNT;
- case 1:
- return NULL_VALUE_COUNT;
- case 2:
- return NAN_VALUE_COUNT;
- case 3:
- return AVG_VALUE_SIZE;
- case 4:
- return MAX_VALUE_SIZE;
- case 5:
- return LOWER_BOUND;
- case 6:
- return UPPER_BOUND;
- case 7:
- return EXACT_BOUNDS;
- default:
- throw new IllegalArgumentException("Invalid statistic offset: " +
offset);
- }
+ /**
+ * Returns the {@link FieldStatistic} from its position (0-based) in the
stats structure
+ *
+ * @param position The position (0-based) in the stats structure
+ * @return The {@link FieldStatistic} from its position (0-based) in the
stats structure
+ */
+ public static FieldStatistic fromPosition(int position) {
+ return switch (position) {
+ case 0 -> VALUE_COUNT;
+ case 1 -> NULL_VALUE_COUNT;
+ case 2 -> NAN_VALUE_COUNT;
+ case 3 -> AVG_VALUE_SIZE;
+ case 4 -> MAX_VALUE_SIZE;
+ case 5 -> LOWER_BOUND;
+ case 6 -> UPPER_BOUND;
+ case 7 -> EXACT_BOUNDS;
+ default -> throw new IllegalArgumentException("Invalid statistic
position: " + position);
+ };
}
- public static Types.StructType fieldStatsFor(Type type, int fieldId) {
+ public static Types.StructType fieldStatsFor(Type type, int baseFieldId) {
Review Comment:
we used to always pass `baseFieldId + 1` here instead of just the
`baseFieldId`
--
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]