anoopj commented on code in PR #18108:
URL: https://github.com/apache/iceberg/pull/18108#discussion_r4139992426


##########
core/src/main/java/org/apache/iceberg/TrackedFileStruct.java:
##########
@@ -210,14 +214,34 @@ public long fileSizeInBytes() {
     return fileSizeInBytes;
   }
 
+  void setPartitionType(Types.StructType newPartitionType) {
+    this.projectedPartition = project(partitionData, newPartitionType);
+  }
+
   @Override
   public Integer specId() {
     return specId;
   }
 
   @Override
   public StructLike partition() {
-    return partitionData;
+    return projectedPartition != null ? projectedPartition : partitionData;
+  }
+
+  private static PartitionData copyOf(PartitionData partition) {
+    return partition != null ? partition.copy() : null;
+  }
+
+  private static PartitionData project(PartitionData partition, 
Types.StructType partitionType) {

Review Comment:
   Thanks for the suggestion! This is much better. I changed it such that the 
projection is created once per spec ID and  cached in the reader, and set on 
each struct.  `partition()` just applies the pre-built projection, or returns 
the tuple as-is when there's none.



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