yihua commented on code in PR #11131: URL: https://github.com/apache/hudi/pull/11131#discussion_r1595849923
########## hudi-common/src/main/java/org/apache/hudi/common/config/PropertiesConfig.java: ########## @@ -0,0 +1,33 @@ +/* + * 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.config; + +/** + * Used for loading filesystem specific configs + */ +public abstract class PropertiesConfig { + Review Comment: nit: remove empty line ########## hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java: ########## @@ -209,21 +193,7 @@ public static List<String> getAllPartitionFoldersThreeLevelsDown(HoodieStorage s * Given a base partition and a partition path, return relative path of partition path to the base path. */ public static String getRelativePartitionPath(Path basePath, Path fullPartitionPath) { - basePath = CachingPath.getPathWithoutSchemeAndAuthority(basePath); - fullPartitionPath = CachingPath.getPathWithoutSchemeAndAuthority(fullPartitionPath); - - String fullPartitionPathStr = fullPartitionPath.toString(); - - if (!fullPartitionPathStr.startsWith(basePath.toString())) { - throw new IllegalArgumentException("Partition path \"" + fullPartitionPathStr - + "\" does not belong to base-path \"" + basePath + "\""); - } - - int partitionStartIndex = fullPartitionPathStr.indexOf(basePath.getName(), - basePath.getParent() == null ? 0 : basePath.getParent().toString().length()); - // Partition-Path could be empty for non-partitioned tables - return partitionStartIndex + basePath.getName().length() == fullPartitionPathStr.length() ? "" - : fullPartitionPathStr.substring(partitionStartIndex + basePath.getName().length() + 1); + return getRelativePartitionPath(new StoragePath(basePath.toUri()), new StoragePath(fullPartitionPath.toUri())); Review Comment: nit: use `convertToStoragePath(Path)` ########## hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java: ########## @@ -635,16 +603,7 @@ public static Long getSizeInMB(long sizeInBytes) { } public static Path constructAbsolutePathInHadoopPath(String basePath, String relativePartitionPath) { - if (StringUtils.isNullOrEmpty(relativePartitionPath)) { - return new Path(basePath); - } - - // NOTE: We have to chop leading "/" to make sure Hadoop does not treat it like - // absolute path - String properPartitionPath = relativePartitionPath.startsWith(PATH_SEPARATOR) - ? relativePartitionPath.substring(1) - : relativePartitionPath; - return constructAbsolutePath(new CachingPath(basePath), properPartitionPath); + return new Path(constructAbsolutePath(basePath, relativePartitionPath).toUri()); Review Comment: nit: use `convertToPath(StoragePath)` ########## hudi-common/src/main/java/org/apache/hudi/io/storage/HoodieAvroFileWriterFactory.java: ########## @@ -47,6 +48,12 @@ import static org.apache.hudi.io.storage.HoodieHFileConfig.PREFETCH_ON_OPEN; public class HoodieAvroFileWriterFactory extends HoodieFileWriterFactory { + Review Comment: nit: remove empty line ########## hudi-common/src/main/java/org/apache/hudi/common/util/BaseFileUtils.java: ########## @@ -56,7 +56,7 @@ public static BaseFileUtils getInstance(String path) { if (path.endsWith(HoodieFileFormat.PARQUET.getFileExtension())) { return new ParquetUtils(); } else if (path.endsWith(HoodieFileFormat.ORC.getFileExtension())) { - return new OrcUtils(); + return ReflectionUtils.loadClass("org.apache.hudi.common.util.OrcUtils"); Review Comment: nit: final static variable for `org.apache.hudi.common.util.OrcUtils`. ########## hudi-common/src/test/java/org/apache/hudi/common/testutils/HoodieTestUtils.java: ########## @@ -209,13 +217,14 @@ public static HoodieTableMetaClient createMetaClient(StorageConfiguration<?> sto } /** - * @param conf file system configuration. - * @param basePath base path of the Hudi table. + * @param conf storage configuration. + * @param basePath base path of the Hudi table. * @return a new {@link HoodieTableMetaClient} instance. */ public static HoodieTableMetaClient createMetaClient(Configuration conf, String basePath) { - return createMetaClient(HadoopFSUtils.getStorageConfWithCopy(conf), basePath); + return HoodieTableMetaClient.builder() + .setConf(HoodieStorageUtils.getStorageConfWithCopy(conf)).setBasePath(basePath).build(); Review Comment: nit: we can revert these changes as the logic is the same. ########## hudi-common/src/main/java/org/apache/hudi/storage/HoodieStorageUtils.java: ########## @@ -19,37 +19,63 @@ package org.apache.hudi.storage; -import org.apache.hudi.hadoop.fs.HadoopFSUtils; -import org.apache.hudi.hadoop.fs.HoodieWrapperFileSystem; -import org.apache.hudi.storage.hadoop.HoodieHadoopStorage; +import org.apache.hudi.common.fs.ConsistencyGuard; +import org.apache.hudi.common.util.ReflectionUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; public class HoodieStorageUtils { + Review Comment: nit: remove empty line ########## hudi-hadoop-common/src/main/java/org/apache/hudi/storage/hadoop/HoodieHadoopStorage.java: ########## @@ -43,16 +47,66 @@ import java.util.List; import java.util.stream.Collectors; +import static org.apache.hudi.common.util.ValidationUtils.checkArgument; import static org.apache.hudi.hadoop.fs.HadoopFSUtils.convertToHadoopPath; import static org.apache.hudi.hadoop.fs.HadoopFSUtils.convertToStoragePath; import static org.apache.hudi.hadoop.fs.HadoopFSUtils.convertToStoragePathInfo; +import static org.apache.hudi.hadoop.fs.HadoopFSUtils.getFs; /** * Implementation of {@link HoodieStorage} using Hadoop's {@link FileSystem} */ public class HoodieHadoopStorage extends HoodieStorage { private final FileSystem fs; + public HoodieHadoopStorage(HoodieStorage storage) { Review Comment: @jonvex have you created a JIRA for this one? ########## hudi-hadoop-common/src/test/java/org/apache/hudi/common/table/timeline/TestWaitBasedTimeGenerator.java: ########## @@ -75,7 +75,7 @@ public boolean tryLock(long time, TimeUnit unit) { // Clock skew time private final long clockSkewTime = 20L; - private final StorageConfiguration<?> storageConf = HadoopFSUtils.getStorageConf(new Configuration()); + private final StorageConfiguration<?> storageConf = HoodieStorageUtils.getNewStorageConf(); Review Comment: This is fixed by using the new test util `getDefaultStorageConfWithDefaults()`. -- 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]
