pvary commented on code in PR #13933: URL: https://github.com/apache/iceberg/pull/13933#discussion_r2375887762
########## core/src/main/java/org/apache/iceberg/stats/BaseFieldStats.java: ########## @@ -0,0 +1,252 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.stats; + +import java.io.Serializable; +import java.util.Objects; +import java.util.StringJoiner; +import org.apache.iceberg.StructLike; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.types.Type; + +public class BaseFieldStats implements FieldStats, StructLike, Serializable { + private final transient int fieldId; + private final transient Type type; + private final Long columnSize; + private final Long valueCount; + private final Long nullValueCount; + private final Long nanValueCount; + private final Object lowerBound; + private final Object upperBound; + + BaseFieldStats( + int fieldId, + Type type, + Long columnSize, + Long valueCount, + Long nullValueCount, + Long nanValueCount, + Object lowerBound, + Object upperBound) { + this.fieldId = fieldId; + this.type = type; + this.columnSize = columnSize; + this.valueCount = valueCount; + this.nullValueCount = nullValueCount; + this.nanValueCount = nanValueCount; + this.lowerBound = lowerBound; + this.upperBound = upperBound; + } + + @Override + public int fieldId() { + return fieldId; + } + + @Override + public Type type() { + return type; + } + + @Override + public Long columnSize() { + return columnSize; + } + + @Override + public Long valueCount() { + return valueCount; + } + + @Override + public Long nullValueCount() { + return nullValueCount; + } + + @Override + public Long nanValueCount() { + return nanValueCount; + } + + @Override + public Object lowerBound() { + return lowerBound; + } + + @Override + public Object upperBound() { + return upperBound; + } + + @Override + public int size() { + return 6; + } + + @Override + public Object get(int pos, Class javaClass) { + switch (pos) { + case StatsUtil.COLUMN_SIZE_OFFSET: + return javaClass.cast(columnSize); + case StatsUtil.VALUE_COUNT_OFFSET: + return javaClass.cast(valueCount); + case StatsUtil.NULL_VALUE_COUNT_OFFSET: + return javaClass.cast(nullValueCount); + case StatsUtil.NAN_VALUE_COUNT_OFFSET: + return javaClass.cast(nanValueCount); + case StatsUtil.LOWER_BOUND_OFFSET: + return javaClass.cast(lowerBound); + case StatsUtil.UPPER_BOUND_OFFSET: + return javaClass.cast(upperBound); + default: + throw new UnsupportedOperationException("Unknown field ordinal: " + pos); + } + } + + @Override + public void set(int pos, Object value) { + throw new UnsupportedOperationException("set() not supported"); + } + + @Override + public String toString() { + return new StringJoiner(", ", BaseFieldStats.class.getSimpleName() + "[", "]") Review Comment: nit: Maybe use MoreObjects here as well -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org