yihua commented on code in PR #11171:
URL: https://github.com/apache/hudi/pull/11171#discussion_r1595058459
##########
hudi-common/src/main/java/org/apache/hudi/io/storage/HoodieAvroFileReaderFactory.java:
##########
@@ -63,8 +67,13 @@ protected HoodieFileReader newHFileFileReader(HoodieConfig
hoodieConfig,
if (isUseNativeHFileReaderEnabled(hoodieConfig)) {
return new HoodieNativeAvroHFileReader(conf, content, schemaOption);
}
- CacheConfig cacheConfig = new
CacheConfig(conf.unwrapAs(Configuration.class));
- return new HoodieHBaseAvroHFileReader(conf, path, cacheConfig, storage,
content, schemaOption);
+ try {
+ return (HoodieFileReader)
ReflectionUtils.loadClass("org.apache.hudi.io.storage.HoodieHBaseAvroHFileReader",
+ new Class<?>[] {StorageConfiguration.class, StoragePath.class,
HoodieStorage.class, byte[].class, Option.class},
+ conf, path, storage, content, schemaOption);
+ } catch (HoodieException e) {
+ throw (IOException) e.getCause().getCause();
Review Comment:
same here.
##########
hudi-common/src/main/java/org/apache/hudi/io/storage/HoodieAvroFileReaderFactory.java:
##########
@@ -45,11 +44,16 @@ protected HoodieFileReader newHFileFileReader(HoodieConfig
hoodieConfig,
if (isUseNativeHFileReaderEnabled(hoodieConfig)) {
return new HoodieNativeAvroHFileReader(conf, path, schemaOption);
}
- CacheConfig cacheConfig = new
CacheConfig(conf.unwrapAs(Configuration.class));
- if (schemaOption.isPresent()) {
- return new HoodieHBaseAvroHFileReader(conf, path, cacheConfig,
HoodieStorageUtils.getStorage(path, conf), schemaOption);
+ try {
+ if (schemaOption.isPresent()) {
+ return (HoodieFileReader)
ReflectionUtils.loadClass("org.apache.hudi.io.storage.HoodieHBaseAvroHFileReader",
+ new Class<?>[] {StorageConfiguration.class, StoragePath.class,
Option.class}, conf, path, schemaOption);
+ }
+ return (HoodieFileReader)
ReflectionUtils.loadClass("org.apache.hudi.io.storage.HoodieHBaseAvroHFileReader",
+ new Class<?>[] {StorageConfiguration.class, StoragePath.class},
conf, path);
+ } catch (HoodieException e) {
+ throw (IOException) e.getCause().getCause();
Review Comment:
Throw `new HoodieException("Cannot instantiate HoodieHBaseAvroHFileReader",
e)`?
##########
hudi-hadoop-common/src/main/java/org/apache/hudi/io/storage/HoodieHBaseAvroHFileReader.java:
##########
@@ -95,16 +96,29 @@ public HoodieHBaseAvroHFileReader(StorageConfiguration<?>
storageConf, StoragePa
this(path, HoodieStorageUtils.getStorage(path, storageConf), storageConf,
cacheConfig, Option.empty());
}
+ public HoodieHBaseAvroHFileReader(StorageConfiguration<?> storageConf,
StoragePath path, Option<Schema> schemaOpt) throws IOException {
+ this(storageConf, path, new
CacheConfig(storageConf.unwrapAs(Configuration.class)), new
HoodieHadoopStorage(path, storageConf), schemaOpt);
+ }
+
public HoodieHBaseAvroHFileReader(StorageConfiguration<?> storageConf,
StoragePath path, CacheConfig cacheConfig,
HoodieStorage storage, Option<Schema>
schemaOpt) throws IOException {
this(path, storage, storageConf, cacheConfig, schemaOpt);
}
+ public HoodieHBaseAvroHFileReader(StorageConfiguration<?> storageConf,
StoragePath path, HoodieStorage storage,
Review Comment:
Do we still need other constructors? There are many.
##########
hudi-hadoop-common/src/test/java/org/apache/hudi/common/bootstrap/index/HFileBootstrapIndexHadoopWriter.java:
##########
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.common.bootstrap.index;
+
+import org.apache.hudi.avro.model.HoodieBootstrapFilePartitionInfo;
+import org.apache.hudi.avro.model.HoodieBootstrapIndexInfo;
+import org.apache.hudi.avro.model.HoodieBootstrapPartitionMetadata;
+import org.apache.hudi.common.model.BootstrapFileMapping;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.TimelineMetadataUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.collection.Pair;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.exception.HoodieIOException;
+import org.apache.hudi.storage.StoragePath;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.io.hfile.CacheConfig;
+import org.apache.hadoop.hbase.io.hfile.HFile;
+import org.apache.hadoop.hbase.io.hfile.HFileContext;
+import org.apache.hadoop.hbase.io.hfile.HFileContextBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static
org.apache.hudi.common.bootstrap.index.HFileBootstrapIndex.INDEX_INFO_KEY;
+import static
org.apache.hudi.common.bootstrap.index.HFileBootstrapIndex.fileIdIndexPath;
+import static
org.apache.hudi.common.bootstrap.index.HFileBootstrapIndex.getFileGroupKey;
+import static
org.apache.hudi.common.bootstrap.index.HFileBootstrapIndex.getPartitionKey;
+import static
org.apache.hudi.common.bootstrap.index.HFileBootstrapIndex.partitionIndexPath;
+import static org.apache.hudi.common.util.StringUtils.getUTF8Bytes;
+
+public class HFileBootstrapIndexHadoopWriter extends
BootstrapIndex.IndexWriter {
Review Comment:
Rename this to `HBaseHFileBootstrapIndexWriter` to be consistent with the
naming convention of the bootstrap index reader.
--
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]