hudi-agent commented on code in PR #19000:
URL: https://github.com/apache/hudi/pull/19000#discussion_r3409077417


##########
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java:
##########
@@ -276,15 +276,21 @@ public static Map<String, 
HoodieColumnRangeMetadata<Comparable>> collectColumnRa
     final Properties properties = new Properties();
     properties.setProperty(HoodieStorageConfig.WRITE_UTC_TIMEZONE.key(),
         storageConfig.getString(HoodieStorageConfig.WRITE_UTC_TIMEZONE.key(), 
HoodieStorageConfig.WRITE_UTC_TIMEZONE.defaultValue().toString()));
+    // getNonNullType() rebuilds the union-member wrappers for nullable fields 
and depends only on the
+    // (fixed) target fields, so resolve it once per field instead of once per 
record per field. Holding
+    // a stable HoodieSchema instance also lets its toAvroSchema() memoize 
across records.
+    List<Pair<String, HoodieSchema>> nonNullFieldSchemas = new 
ArrayList<>(targetFields.size());
+    for (Pair<String, HoodieSchemaField> fieldNameFieldPair : targetFields) {

Review Comment:
   🤖 nit: the rest of this method uses `.forEach`/`.forEachRemaining` 
(functional style), so the explicit `for` loop here reads as slightly 
inconsistent. Could you use a stream instead? e.g. `targetFields.stream().map(p 
-> Pair.of(p.getKey(), 
p.getValue().schema().getNonNullType())).collect(Collectors.toList())` — it 
also makes line 284 much shorter.
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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