hililiwei commented on code in PR #6222:
URL: https://github.com/apache/iceberg/pull/6222#discussion_r1051380948


##########
core/src/main/java/org/apache/iceberg/BaseFilesTable.java:
##########
@@ -223,34 +225,28 @@ ManifestFile manifest() {
   static class ContentFileStructWithMetrics implements StructLike {
     private final StructLike fileAsStruct;
     private final MetricsUtil.ReadableMetricsStruct readableMetrics;
-    private final int expectedSize;
+    private final int position;
 
     ContentFileStructWithMetrics(
-        int expectedSize,
-        StructLike fileAsStruct,
-        MetricsUtil.ReadableMetricsStruct readableMetrics) {
+        int position, StructLike fileAsStruct, 
MetricsUtil.ReadableMetricsStruct readableMetrics) {
       this.fileAsStruct = fileAsStruct;
       this.readableMetrics = readableMetrics;
-      this.expectedSize = expectedSize;
+      this.position = position;
     }
 
     @Override
     public int size() {
-      return expectedSize;
+      return position;
     }
 
     @Override
     public <T> T get(int pos, Class<T> javaClass) {
-      int lastExpectedIndex = expectedSize - 1;
-      if (pos < lastExpectedIndex) {
+      if (pos < position) {
         return fileAsStruct.get(pos, javaClass);
-      } else if (pos == lastExpectedIndex) {
+      } else if (pos == position) {
         return javaClass.cast(readableMetrics);
       } else {
-        throw new IllegalArgumentException(

Review Comment:
   metrics occupies a position.  `fileAsStruct` size + `Metrics` size(is 1) is 
equal to the size of `projection`. 
   
   When pos is greater than metricsPosition, the actual position of the field 
in `fileAsStruct` should be subtracted by 1.
   For instance:
   ```
   fileAsStruct :[0->c1, 1->c2]
   metrics :[0->c3]
   project:[c1,c3,c2]
   ```
   When we want to get `c2` (its pos is 2), but actually 1 in `fileAsStruct`.



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

Reply via email to