danny0405 commented on code in PR #13580:
URL: https://github.com/apache/hudi/pull/13580#discussion_r2253854045
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/FileGroupReaderBasedMergeHandle.java:
##########
@@ -289,4 +338,112 @@ private GenericRecord convertOutput(T record) {
return convertedRecord == null ? null :
readerContext.convertToAvroRecord(convertedRecord, requestedSchema.get());
}
}
+
+ private static class SecondaryIndexCallback<T> implements
BaseFileUpdateCallback<T> {
+ private final String partitionPath;
+ private final Schema writeSchemaWithMetaFields;
+ private final HoodieReaderContext<T> readerContext;
+ private final Supplier<Schema> newSchemaSupplier;
+ private final WriteStatus writeStatus;
+ private final List<HoodieIndexDefinition> secondaryIndexDefns;
+ private final Option<BaseKeyGenerator> keyGeneratorOpt;
+ private final HoodieWriteConfig config;
+
+ public SecondaryIndexCallback(String partitionPath,
+ Schema writeSchemaWithMetaFields,
+ HoodieReaderContext<T> readerContext,
+ Supplier<Schema> newSchemaSupplier,
+ WriteStatus writeStatus,
+ List<HoodieIndexDefinition>
secondaryIndexDefns,
+ Option<BaseKeyGenerator> keyGeneratorOpt,
+ HoodieWriteConfig config) {
+ this.partitionPath = partitionPath;
+ this.writeSchemaWithMetaFields = writeSchemaWithMetaFields;
+ this.readerContext = readerContext;
+ this.newSchemaSupplier = newSchemaSupplier;
+ this.secondaryIndexDefns = secondaryIndexDefns;
+ this.keyGeneratorOpt = keyGeneratorOpt;
+ this.writeStatus = writeStatus;
+ this.config = config;
+ }
+
+ @Override
+ public void onUpdate(String recordKey, T previousRecord, T mergedRecord) {
+ HoodieKey hoodieKey = new HoodieKey(recordKey, partitionPath);
+ BufferedRecord<T> bufferedPreviousRecord =
BufferedRecord.forRecordWithContext(
+ previousRecord, writeSchemaWithMetaFields, readerContext,
Option.empty(), false);
+ BufferedRecord<T> bufferedMergedRecord =
BufferedRecord.forRecordWithContext(
+ mergedRecord, writeSchemaWithMetaFields, readerContext,
Option.empty(), false);
+ SecondaryIndexStreamingTracker.trackSecondaryIndexStats(
+ hoodieKey,
+ Option.of(readerContext.constructHoodieRecord(bufferedMergedRecord)),
+ readerContext.constructHoodieRecord(bufferedPreviousRecord),
+ false,
+ writeStatus,
+ writeSchemaWithMetaFields,
+ newSchemaSupplier,
+ secondaryIndexDefns,
+ keyGeneratorOpt,
+ config);
+ }
+
+ @Override
+ public void onInsert(String recordKey, T newRecord) {
+ HoodieKey hoodieKey = new HoodieKey(recordKey, partitionPath);
+ BufferedRecord<T> bufferedNewRecord =
BufferedRecord.forRecordWithContext(
+ newRecord, writeSchemaWithMetaFields, readerContext, Option.empty(),
false);
+ SecondaryIndexStreamingTracker.trackSecondaryIndexStats(
+ hoodieKey,
+ Option.of(readerContext.constructHoodieRecord(bufferedNewRecord)),
+ null,
+ false,
+ writeStatus,
+ writeSchemaWithMetaFields,
+ newSchemaSupplier,
+ secondaryIndexDefns,
+ keyGeneratorOpt,
+ config);
+ }
+
+ @Override
+ public void onDelete(String recordKey, T previousRecord) {
+ HoodieKey hoodieKey = new HoodieKey(recordKey, partitionPath);
+ BufferedRecord<T> bufferedPreviousRecord =
BufferedRecord.forRecordWithContext(
+ previousRecord, writeSchemaWithMetaFields, readerContext,
Option.empty(), false);
+ SecondaryIndexStreamingTracker.trackSecondaryIndexStats(
+ hoodieKey,
+ null,
+ readerContext.constructHoodieRecord(bufferedPreviousRecord),
+ true,
+ writeStatus,
+ writeSchemaWithMetaFields,
+ newSchemaSupplier,
+ secondaryIndexDefns,
+ keyGeneratorOpt,
+ config);
+ }
+ }
+
+ private static class CompositeCallback<T> implements
BaseFileUpdateCallback<T> {
Review Comment:
We can implement RLI tracing in similiair way.
--
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]