the-other-tim-brown commented on code in PR #1016:
URL: https://github.com/apache/incubator-xtable/pull/1016#discussion_r4698655250


##########
xtable-core/src/main/java/org/apache/xtable/paimon/PaimonStatsExtractor.java:
##########
@@ -83,6 +93,32 @@ public List<ColumnStat> extractColumnStats(DataFileMeta 
file, InternalSchema int
     return columnStats;
   }
 
+  /**
+   * Maps the column names of the file's schema to the fields of the schema 
the stats are reported
+   * in. Columns are matched by field id, since a column can be renamed, 
dropped or added after the
+   * file was written. A column whose type changed is left out, since the file 
stores its stats in
+   * the old type.
+   */
+  private static Map<String, InternalField> getFieldsByFileColumnName(
+      InternalSchema fileSchema, InternalSchema internalSchema) {
+    Map<Integer, InternalField> fieldsById =
+        internalSchema.getFields().stream()
+            .collect(Collectors.toMap(InternalField::getFieldId, f -> f));

Review Comment:
   Nitpick: `f -> f` can just be `Function.identity()`



##########
xtable-core/src/main/java/org/apache/xtable/paimon/PaimonStatsExtractor.java:
##########
@@ -83,6 +93,32 @@ public List<ColumnStat> extractColumnStats(DataFileMeta 
file, InternalSchema int
     return columnStats;
   }
 
+  /**
+   * Maps the column names of the file's schema to the fields of the schema 
the stats are reported
+   * in. Columns are matched by field id, since a column can be renamed, 
dropped or added after the
+   * file was written. A column whose type changed is left out, since the file 
stores its stats in
+   * the old type.
+   */
+  private static Map<String, InternalField> getFieldsByFileColumnName(

Review Comment:
   I think we can optimize this a bit. When the `fileSchema` and 
`internalSchema` are the same we don't need to run the loop in this method. The 
main run mode is incremental so I'd expect this case is the most common.



##########
xtable-core/src/main/java/org/apache/xtable/paimon/PaimonDataFileExtractor.java:
##########
@@ -159,6 +173,14 @@ public InternalFilesDiff extractFilesDiff(
     return 
InternalFilesDiff.builder().filesAdded(addedFiles).filesRemoved(removedFiles).build();
   }
 
+  /** Returns a lookup of the table's schemas by id that reads each schema 
once. */
+  private Function<Long, InternalSchema> fileSchemaLookup(FileStoreTable 
table) {

Review Comment:
   What is the reasoning behind using a `Function` for this? We could pass 
around a map. 
   
   Is there any concern for the size of this map for large tables with lots of 
history?



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

Reply via email to