danny0405 commented on code in PR #13449:
URL: https://github.com/apache/hudi/pull/13449#discussion_r2159849498
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieWriteHandle.java:
##########
@@ -103,9 +114,34 @@ protected HoodieWriteHandle(HoodieWriteConfig config,
String instantTime, String
this.taskContextSupplier = taskContextSupplier;
this.writeToken = makeWriteToken();
this.schemaOnReadEnabled =
!isNullOrEmpty(hoodieTable.getConfig().getInternalSchema());
+ this.preserveMetadata = preserveMetadata;
this.recordMerger = config.getRecordMerger();
this.writeStatus = (WriteStatus)
ReflectionUtils.loadClass(config.getWriteStatusClassName(),
hoodieTable.shouldTrackSuccessRecords(),
config.getWriteStatusFailureFraction(), hoodieTable.isMetadataTable());
+ boolean isMetadataStreamingWritesEnabled =
config.isMetadataStreamingWritesEnabled(hoodieTable.getMetaClient().getTableConfig().getTableVersion());
+ if (isMetadataStreamingWritesEnabled) {
+ initMetadataPartitionsToCollectStats(preserveMetadata);
+ this.isSecondaryIndexStatsStreamingWritesEnabled =
!secondaryIndexDefns.isEmpty();
+ } else {
+ this.isSecondaryIndexStatsStreamingWritesEnabled = false;
+ }
+ }
+
+ private void initMetadataPartitionsToCollectStats(boolean preserveMetadata) {
+ // Secondary index should not be updated for clustering and compaction
+ // Since for clustering and compaction preserveMetadata is true, we are
checking for it before enabling secondary index update
+ if (config.isSecondaryIndexEnabled() && !preserveMetadata) {
+ ValidationUtils.checkArgument(recordMerger.getRecordType() ==
HoodieRecord.HoodieRecordType.AVRO,
+ "Only Avro record type is supported for streaming writes to metadata
table with write handles");
+ secondaryIndexDefns = hoodieTable.getMetaClient().getIndexMetadata()
Review Comment:
instead of maintain the pairs of `(indexName -> index definition)`, we
should maintain the `(indexName -> index source fields)` by using the
`String.join(".",
secondaryIndexPartitionPathFieldPair.getValue().getSourceFields())`
to avoid unnecessary computation per-record.
--
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]