hudi-agent commented on code in PR #19502:
URL: https://github.com/apache/hudi/pull/19502#discussion_r3719431857
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala:
##########
@@ -314,21 +315,42 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath:
String,
} else {
0
}
- val reader = HoodieFileGroupReader.builder()
- .withReaderContext(readerContext)
- .withHoodieTableMetaClient(metaClient)
- .withLatestCommitTime(queryTimestamp)
- .withBaseFileOption(fileSlice.getBaseFile)
- .withLogFiles(fileSlice.getLogFiles)
- .withPartitionPath(fileSlice.getPartitionPath)
- .withDataSchema(dataSchema)
- .withRequestedSchema(requestedSchema)
- .withInternalSchemaOpt(internalSchemaOpt)
- .withProps(props)
- .withStart(file.start)
- .withLength(baseFileLength)
- .withShouldUseRecordPosition(shouldUseRecordPosition)
- .build()
+ val reader: HoodieRecordReader[InternalRow] =
+ if (!metaClient.isMetadataTable &&
LsmReaderUtils.shouldUseLsmReader(
+ metaClient.getTableConfig,
+ fileSlice.getLogFiles,
+ ConfigUtils.getStringWithAltKeys(props,
HoodieReaderConfig.MERGE_TYPE, true))) {
+ HoodieLsmFileGroupReader.builder[InternalRow]()
+ .withReaderContext(readerContext)
+ .withHoodieTableMetaClient(metaClient)
+ .withLatestCommitTime(queryTimestamp)
+ .withBaseFileOption(fileSlice.getBaseFile)
+ .withLogFiles(fileSlice.getLogFiles)
+ .withPartitionPath(fileSlice.getPartitionPath)
+ .withDataSchema(dataSchema)
+ .withRequestedSchema(requestedSchema)
+ .withInternalSchemaOpt(internalSchemaOpt)
+ .withProps(props)
+ .withStart(file.start)
+ .withLength(baseFileLength)
+ .build()
+ } else {
Review Comment:
🤖 nit: the two builder branches share ~12 identical `.withX()` calls and
only differ in `.withShouldUseRecordPosition(...)`. Could you extract the
shared setup into a local helper or a partially-constructed builder, so a
future author adding a new `withX()` option doesn't have to remember to update
both branches?
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag
quality.</i></sub>
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieMergeOnReadRDDV2.scala:
##########
@@ -191,18 +192,35 @@ class HoodieMergeOnReadRDDV2(@transient sc: SparkContext,
} else {
val readerContext = new
SparkFileFormatInternalRowReaderContext(fileGroupBaseFileReader.value,
optionalFilters,
Seq.empty, storageConf, metaClient.getTableConfig)
- val fileGroupReader = HoodieFileGroupReader.builder()
- .withReaderContext(readerContext)
- .withHoodieTableMetaClient(metaClient)
- .withLatestCommitTime(tableState.latestCommitTimestamp.orNull)
- .withLogFiles(logFiles.stream())
- .withBaseFileOption(baseFileOption)
- .withPartitionPath(partitionPath)
- .withProps(properties)
- .withDataSchema(tableSchema.schema)
- .withRequestedSchema(requiredSchema.schema)
-
.withInternalSchemaOpt(HOption.ofNullable(tableSchema.internalSchema.orNull))
- .build()
+ val fileGroupReader: HoodieRecordReader[InternalRow] =
+ if (!metaClient.isMetadataTable
+ && LsmReaderUtils.shouldUseLsmReader(metaClient.getTableConfig,
logFiles.stream(), mergeType)) {
+ HoodieLsmFileGroupReader.builder[InternalRow]()
+ .withReaderContext(readerContext)
+ .withHoodieTableMetaClient(metaClient)
+ .withLatestCommitTime(tableState.latestCommitTimestamp.orNull)
+ .withLogFiles(logFiles.stream())
+ .withBaseFileOption(baseFileOption)
+ .withPartitionPath(partitionPath)
+ .withProps(properties)
+ .withDataSchema(tableSchema.schema)
+ .withRequestedSchema(requiredSchema.schema)
+
.withInternalSchemaOpt(HOption.ofNullable(tableSchema.internalSchema.orNull))
+ .build()
+ } else {
+ HoodieFileGroupReader.builder[InternalRow]()
Review Comment:
🤖 nit: same pattern as `HoodieFileGroupReaderBasedFileFormat` — both reader
branches duplicate all builder options. It might be worth consolidating the
shared lines to make the if/else diff obvious at a glance.
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag
quality.</i></sub>
--
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]