RussellSpitzer commented on code in PR #4560:
URL: https://github.com/apache/iceberg/pull/4560#discussion_r855549382


##########
core/src/main/java/org/apache/iceberg/PartitionsTable.java:
##########
@@ -93,16 +96,77 @@ private static StaticDataTask.Row 
convertPartition(Partition partition) {
     return StaticDataTask.Row.of(partition.key, partition.recordCount, 
partition.fileCount, partition.specId);
   }
 
-  private static Iterable<Partition> partitions(StaticTableScan scan) {
+  private static Iterable<Partition> partitions(Table table, StaticTableScan 
scan) {
     CloseableIterable<FileScanTask> tasks = planFiles(scan);
+    Types.StructType normalizedPartitionType = 
Partitioning.partitionType(table);
+    PartitionMap partitions = new PartitionMap();
+
+    LoadingCache<Integer, Integer[]> originalPartitionFieldPositionsBySpec = 
Caffeine.newBuilder().build(specId ->
+        originalPositions(table, specId, normalizedPartitionType));
+    LoadingCache<Pair<PartitionData, Integer>, PartitionData> 
normalizedPartitions = Caffeine.newBuilder().build(
+        pData -> normalizePartition(pData, normalizedPartitionType, 
originalPartitionFieldPositionsBySpec));
 
-    PartitionMap partitions = new 
PartitionMap(scan.table().spec().partitionType());
     for (FileScanTask task : tasks) {
-      partitions.get(task.file().partition()).update(task.file());
+      PartitionData original = (PartitionData) task.file().partition();
+      int specId = task.spec().specId();

Review Comment:
   I was thinking this would look something more like
   ```
   positionMapping = originalPositions.computeIfAbsent(specId, specId -> 
originalPositions())
   make normalizedPartitionData
   for (originalIndex = 0; originalIndex < original.length; originalIndex ++) {
      normalizedPartitionData.put(positionMapping[originalIndex], 
original.get(originalIndex))
   }
   ```
   
   This could be a separate function like we have now but I don't know if it's 
that bad if we just inline it here



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