cshuo commented on code in PR #19804:
URL: https://github.com/apache/hudi/pull/19804#discussion_r3930254759
##########
hudi-common/src/main/java/org/apache/hudi/common/table/log/AbstractHoodieLogRecordScanner.java:
##########
@@ -220,7 +228,33 @@ protected AbstractHoodieLogRecordScanner(HoodieStorage
storage, String basePath,
}
this.partitionNameOverrideOpt = partitionNameOverride;
+ this.deletePartitionPathOpt = resolveDeletePartitionPath(basePath,
logFilePaths, partitionNameOverride);
this.recordType = recordMerger.getRecordType();
+ this.readerContext = readerContext;
+ }
+
+ private static Option<String> resolveDeletePartitionPath(String basePath,
List<String> logFilePaths,
+ Option<String>
partitionNameOverride) {
+ if (partitionNameOverride.isPresent()) {
+ return partitionNameOverride;
+ }
+ if (logFilePaths.isEmpty()) {
+ return Option.empty();
+ }
+ return Option.of(getRelativePartitionPath(
+ new StoragePath(basePath), new
StoragePath(logFilePaths.get(0)).getParent()));
+ }
+
+ private <T> void initializeReaderContext(HoodieReaderContext<T>
readerContext) {
+ if (!isReaderContextInitialized) {
Review Comment:
Could we initialize the reader context directly in the constructor? This now
only sets fields whose values are already available at construction time, so
lazy initialization is unnecessary. This would also remove
`isReaderContextInitialized` and the initialization call from
`processDeleteBlock`.
##########
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/realtime/AbstractRealtimeRecordReader.java:
##########
@@ -214,4 +217,14 @@ public HoodieSchema
constructHiveOrderedSchema(HoodieSchema writerSchema, Map<St
protected HoodieSchema getLogScannerReaderSchema() {
return usesCustomPayload ? writerSchema : readerSchema;
}
+
+ /**
+ * Creates a reader context using the table configuration and the complete
Hadoop runtime configuration.
+ */
+ protected HoodieReaderContext<IndexedRecord> createReaderContext() {
+ TypedProperties readerProps =
TypedProperties.copy(metaClient.getTableConfig().getProps(true));
Review Comment:
`getProps(true)` already returns a fresh `TypedProperties` containing global
and table properties, so the extra `TypedProperties.copy(...)` is unnecessary.
Could we remove it here and at the other reader-context construction sites?
--
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]