You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by vi...@apache.org on 2020/10/30 05:33:34 UTC
[hudi] 04/14: [MINOR] Reduced number of fs calls to check for table
existence. Removed dead code.
This is an automated email from the ASF dual-hosted git repository.
vinoth pushed a commit to branch rfc-15
in repository https://gitbox.apache.org/repos/asf/hudi.git
commit 7bea565b860908af0d314e203ad3b20307a62164
Author: Prashant Wason <pw...@uber.com>
AuthorDate: Fri Oct 16 17:15:17 2020 -0700
[MINOR] Reduced number of fs calls to check for table existence. Removed dead code.
---
.../main/java/org/apache/hudi/common/fs/FSUtils.java | 17 -----------------
.../apache/hudi/exception/TableNotFoundException.java | 14 ++++++++------
2 files changed, 8 insertions(+), 23 deletions(-)
diff --git a/hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java b/hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java
index c6725fc..c2338cf 100644
--- a/hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java
+++ b/hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java
@@ -18,7 +18,6 @@
package org.apache.hudi.common.fs;
-import org.apache.hudi.common.config.SerializableConfiguration;
import org.apache.hudi.common.model.HoodieFileFormat;
import org.apache.hudi.common.model.HoodieLogFile;
import org.apache.hudi.common.model.HoodiePartitionMetadata;
@@ -565,22 +564,6 @@ public class FSUtils {
}
/**
- * Get the FS implementation for this table.
- * @param path Path String
- * @param hadoopConf Serializable Hadoop Configuration
- * @param consistencyGuardConfig Consistency Guard Config
- * @return HoodieWrapperFileSystem
- */
- public static HoodieWrapperFileSystem getFs(String path, SerializableConfiguration hadoopConf,
- ConsistencyGuardConfig consistencyGuardConfig) {
- FileSystem fileSystem = FSUtils.getFs(path, hadoopConf.newCopy());
- return new HoodieWrapperFileSystem(fileSystem,
- consistencyGuardConfig.isConsistencyCheckEnabled()
- ? new FailSafeConsistencyGuard(fileSystem, consistencyGuardConfig)
- : new NoOpConsistencyGuard());
- }
-
- /**
* Helper to filter out paths under metadata folder when running fs.globStatus.
* @param fs File System
* @param globPath Glob Path
diff --git a/hudi-common/src/main/java/org/apache/hudi/exception/TableNotFoundException.java b/hudi-common/src/main/java/org/apache/hudi/exception/TableNotFoundException.java
index 7666e90..ad34a8e 100644
--- a/hudi-common/src/main/java/org/apache/hudi/exception/TableNotFoundException.java
+++ b/hudi-common/src/main/java/org/apache/hudi/exception/TableNotFoundException.java
@@ -18,9 +18,11 @@
package org.apache.hudi.exception;
+import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import java.io.FileNotFoundException;
import java.io.IOException;
/**
@@ -39,15 +41,15 @@ public class TableNotFoundException extends HoodieException {
}
public static void checkTableValidity(FileSystem fs, Path basePathDir, Path metaPathDir) {
- // Check if the base path is found
+ // Check if the base and meta paths are found
try {
- if (!fs.exists(basePathDir) || !fs.isDirectory(basePathDir)) {
- throw new TableNotFoundException(basePathDir.toString());
- }
- // Check if the meta path is found
- if (!fs.exists(metaPathDir) || !fs.isDirectory(metaPathDir)) {
+ // Since metaPath is within the basePath, it is enough to check the metaPath exists
+ FileStatus status = fs.getFileStatus(metaPathDir);
+ if (!status.isDirectory()) {
throw new TableNotFoundException(metaPathDir.toString());
}
+ } catch (FileNotFoundException e) {
+ throw new TableNotFoundException(metaPathDir.toString());
} catch (IllegalArgumentException e) {
// if the base path is file:///, then we have a IllegalArgumentException
throw new TableNotFoundException(metaPathDir.toString());