aokolnychyi commented on code in PR #2276:
URL: https://github.com/apache/iceberg/pull/2276#discussion_r1016115987


##########
api/src/main/java/org/apache/iceberg/util/StructProjection.java:
##########
@@ -90,6 +91,19 @@ public static StructProjection createAllowMissing(
   private final StructProjection[] nestedProjections;
   private StructLike struct;
 
+  private StructProjection(StructProjection other) {
+    this.type = other.type;
+    this.positionMap =

Review Comment:
   What if do the same optimization trick like in `StructLikeWrapper$copyFor` 
to avoid copying these arrays?
   
   We can have a constructor like this:
   ```
   private StructProjection(
       StructType type, int[] positionMap, StructProjection[] 
nestedProjections) {
     this.type = type;
     this.positionMap = positionMap;
     this.nestedProjections = nestedProjections;
   }
   ``` 
   
   And `copyFor` method like this:
   
   ```
   public StructProjection copyFor(StructLike newStruct) {
     return new StructProjection(type, positionMap, 
nestedProjections).wrap(newStruct);
   }
   ```
   
   This way, we share the arrays in all instances, which should be fine as we 
have a projection per spec and these arrays won't actually change. I did not 
realize we had a separate projection per spec before.



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