pvary commented on code in PR #13933:
URL: https://github.com/apache/iceberg/pull/13933#discussion_r2371942554


##########
api/src/main/java/org/apache/iceberg/stats/FieldStats.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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 org.apache.iceberg.StructLike;
+import org.apache.iceberg.types.Type;
+
+public interface FieldStats extends StructLike {
+  int fieldId();
+
+  Type type();
+
+  Long columnSize();
+
+  Long valueCount();
+
+  Long nullValueCount();
+
+  Long nanValueCount();
+
+  Object lowerBound();

Review Comment:
   > I commented about this in [#13933 
(comment)](https://github.com/apache/iceberg/pull/13933#discussion_r2349170460)
   
   Sorry, I have missed that.
   
   > but do you think we have a strong use case for making `FieldStats` generic 
and use the parameterized type here?
   
   Maybe when we are applying the filters in the ManifestEvalVisitor:
   ```
       @Override
       public <T> Boolean eq(BoundReference<T> ref, Literal<T> lit) {
         int pos = Accessors.toPosition(ref.accessor());
         PartitionFieldSummary fieldStats = stats.get(pos);
         if (fieldStats.lowerBound() == null) {
           return ROWS_CANNOT_MATCH; // values are all null and literal cannot 
contain null
         }
   
         T lower = Conversions.fromByteBuffer(ref.type(), 
fieldStats.lowerBound());
         int cmp = lit.comparator().compare(lower, lit.value());
         if (cmp > 0) {
           return ROWS_CANNOT_MATCH;
         }
   
         T upper = Conversions.fromByteBuffer(ref.type(), 
fieldStats.upperBound());
         cmp = lit.comparator().compare(upper, lit.value());
         if (cmp < 0) {
           return ROWS_CANNOT_MATCH;
         }
   
         return ROWS_MIGHT_MATCH;
       }
   ```
   
   This could be like this:
   ```
       @Override
       public <T> Boolean eq(BoundReference<T> ref, Literal<T> lit) {
         int pos = Accessors.toPosition(ref.accessor());
         FieldStats<T> fieldStats = (FieldStats<T>) stats.get(pos);
         if (fieldStats.lowerBound() == null) {
           return ROWS_CANNOT_MATCH; // values are all null and literal cannot 
contain null
         }
   
         if (lit.comparator().compare(fieldStats.lowerBound(), lit.value()) > 
0) {
           return ROWS_CANNOT_MATCH;
         }
   
         if (lit.comparator().compare(fieldStats.upperBound(), lit.value()) < 
0) {
           return ROWS_CANNOT_MATCH;
         }
   
         return ROWS_MIGHT_MATCH;
       }
   ```
   



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