the-other-tim-brown commented on code in PR #13361:
URL: https://github.com/apache/hudi/pull/13361#discussion_r2109301311
##########
hudi-common/src/main/java/org/apache/hudi/metadata/SecondaryIndexRecordGenerationUtils.java:
##########
@@ -275,25 +197,39 @@ public static HoodieData<HoodieRecord>
readSecondaryKeysFromFileSlices(HoodieEng
} else {
readerSchema = tableSchema;
}
- return createSecondaryIndexGenerator(metaClient, engineType,
logFilePaths, readerSchema, partition, dataFilePath, indexDefinition,
-
metaClient.getActiveTimeline().filterCompletedInstants().lastInstant().map(HoodieInstant::requestedTime).orElse(""));
+ ClosableIterator<Pair<String, String>> secondaryIndexGenerator =
createSecondaryIndexGenerator(readerContextFactory.getContext(), metaClient,
fileSlice, readerSchema, indexDefinition,
+
metaClient.getActiveTimeline().filterCompletedInstants().lastInstant().map(HoodieInstant::requestedTime).orElse(""),
props, false);
+ return new CloseableMappingIterator<>(secondaryIndexGenerator, pair ->
createSecondaryIndexRecord(pair.getKey(), pair.getValue(), partition, false));
});
}
- private static ClosableIterator<HoodieRecord>
createSecondaryIndexGenerator(HoodieTableMetaClient metaClient,
-
EngineType engineType, List<String> logFilePaths,
-
Schema tableSchema, String partition,
-
Option<StoragePath> dataFilePath,
-
HoodieIndexDefinition indexDefinition,
-
String instantTime) throws Exception {
- return new ClosableIterator<HoodieRecord>() {
- private final HoodieFileSliceReader<HoodieRecord> fileSliceReader =
getFileSliceReader(
- metaClient, engineType, logFilePaths, tableSchema, partition,
dataFilePath, instantTime);
- private HoodieRecord nextValidRecord;
+ private static <T> ClosableIterator<Pair<String, String>>
createSecondaryIndexGenerator(HoodieReaderContext<T> readerContext,
+
HoodieTableMetaClient metaClient,
+
FileSlice fileSlice,
+
Schema tableSchema,
+
HoodieIndexDefinition indexDefinition,
+
String instantTime,
+
TypedProperties props,
+
boolean allowInflightInstants) throws Exception {
+ String secondaryKeyField = String.join(".",
indexDefinition.getSourceFields());
+ HoodieFileGroupReader<T> fileGroupReader =
HoodieFileGroupReader.<T>newBuilder()
+ .withReaderContext(readerContext)
+ .withFileSlice(fileSlice)
+ .withHoodieTableMetaClient(metaClient)
+ .withProps(props)
+ .withLatestCommitTime(instantTime)
+ .withDataSchema(tableSchema)
+ .withRequestedSchema(tableSchema)
Review Comment:
We can just read the required fields here but we don't have a clean utility
to construct the optimal schema yet so I have added the context to this
existing ticket: https://issues.apache.org/jira/browse/HUDI-9439
--
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]