danny0405 commented on code in PR #11153:
URL: https://github.com/apache/hudi/pull/11153#discussion_r1590454600
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieMergedReadHandle.java:
##########
@@ -52,23 +59,55 @@
public class HoodieMergedReadHandle<T, I, K, O> extends HoodieReadHandle<T, I,
K, O> {
protected final Schema readerSchema;
+ private final Option<FileSlice> fileSliceOpt;
+ private final HoodieTableMetaClient metaClient;
+ private final TaskContextSupplier taskContextSupplier;
public HoodieMergedReadHandle(HoodieWriteConfig config,
Option<String> instantTime,
HoodieTable<T, I, K, O> hoodieTable,
Pair<String, String> partitionPathFileIDPair) {
+ this(config, instantTime, hoodieTable, hoodieTable.getMetaClient(),
hoodieTable.getTaskContextSupplier(),
+ partitionPathFileIDPair, Option.empty());
+ }
+
+ public HoodieMergedReadHandle(HoodieWriteConfig config,
+ Option<String> instantTime,
+ HoodieTable<T, I, K, O> hoodieTable,
+ HoodieTableMetaClient metaClient,
+ TaskContextSupplier taskContextSupplier,
+ Pair<String, String> partitionPathFileIDPair,
+ Option<FileSlice> fileSliceOption) {
super(config, instantTime, hoodieTable, partitionPathFileIDPair);
readerSchema = HoodieAvroUtils.addMetadataFields(new
Schema.Parser().parse(config.getSchema()),
config.allowOperationMetadataField());
+ if (hoodieTable != null) {
+ this.metaClient = hoodieTable.getMetaClient();
+ } else {
+ this.metaClient = metaClient;
+ }
+ if (this.storage == null) {
+ this.storage = this.metaClient.getStorage();
+ this.fs = (FileSystem) this.storage.getFileSystem();
+ }
+ this.taskContextSupplier = taskContextSupplier;
+ fileSliceOpt = fileSliceOption.isPresent() ? fileSliceOption :
getLatestFileSlice();
+ }
+
+ @Override
+ public HoodieStorage getStorage() {
+ // constructor in HoodieIOHandle calls this. We do have two different
code paths, where either of HoodieTable is null or meta client.
+ // In case metaClient not being null, we can set fileSystem after the
constructor of HoodieIOHandle is called. Hence return null in the interim.
Review Comment:
Can we create both of them on the fly, why we need this complexity?
--
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]