voonhous commented on code in PR #19000:
URL: https://github.com/apache/hudi/pull/19000#discussion_r3418712481
##########
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:
Done, switched to a stream.
##########
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.
Review Comment:
Good point - `toAvroSchema()` is just the Lombok getter, no memoization.
Dropped the memoize clause from the comment and reworded the PR description
(Summary/Impact/Risk) so it no longer implies a per-record Avro conversion; the
real win is the per-record `getNonNullType()` hoist.
--
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]