danny0405 commented on code in PR #13449:
URL: https://github.com/apache/hudi/pull/13449#discussion_r2156038664
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieWriteHandle.java:
##########
@@ -106,6 +114,31 @@ protected HoodieWriteHandle(HoodieWriteConfig config,
String instantTime, String
this.recordMerger = config.getRecordMerger();
this.writeStatus = (WriteStatus)
ReflectionUtils.loadClass(config.getWriteStatusClassName(),
hoodieTable.shouldTrackSuccessRecords(),
config.getWriteStatusFailureFraction(), hoodieTable.isMetadataTable());
+ this.isStreamingWriteToMetadataEnabled =
config.isMetadataStreamingWritesEnabled(hoodieTable.getMetaClient().getTableConfig().getTableVersion());
+ initMetadataPartitionsToCollectStats();
+ }
+
+ private void initMetadataPartitionsToCollectStats() {
+ if (isStreamingWriteToMetadataEnabled) {
+ // secondary index.
+ if (config.isSecondaryIndexEnabled()) {
+ 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().getTableConfig().getMetadataPartitions()
+ .stream()
+ .filter(mdtPartition ->
mdtPartition.startsWith(PARTITION_NAME_SECONDARY_INDEX_PREFIX))
+ .map(mdtPartitionPath -> Pair.of(mdtPartitionPath,
HoodieTableMetadataUtil.getHoodieIndexDefinition(mdtPartitionPath,
hoodieTable.getMetaClient())))
+ .collect(Collectors.toList());
+ secondaryIndexDefns.forEach(pair ->
writeStatus.getIndexStats().instantiateSecondaryIndexStatsForIndex(pair.getKey()));
+ }
+ }
+ }
+
+ /**
+ * Returns true if secondary index streaming is disabled for the table.
+ */
+ boolean isSecondaryIndexStreamingDisabled() {
Review Comment:
> I don't want to introduce
SecondaryIndexStreamingDisabled, isColStatsEnabled, isPartitionStatsEnabled
api to write handle
That's okay if it is straight-forward IMO.
--
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]