This is an automated email from the ASF dual-hosted git repository.
jdere pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 212b428 HIVE-22054: Avoid recursive listing to check if a directory
is empty (Prabhas Kumar Samanta, reviewed by Steve Loughran and Jason Dere)
212b428 is described below
commit 212b4281ee6f138fe0835929531fbf3c36505bff
Author: Jason Dere <[email protected]>
AuthorDate: Sun Aug 4 17:35:01 2019 -0700
HIVE-22054: Avoid recursive listing to check if a directory is empty
(Prabhas Kumar Samanta, reviewed by Steve Loughran and Jason Dere)
---
.../src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java | 7 +++----
.../main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java | 2 +-
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
index 6c17c86..d9d7a53 100755
---
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
+++
b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
@@ -42,7 +42,6 @@ import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.ContentSummary;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -373,9 +372,9 @@ public class Warehouse {
}
}
- public boolean isEmpty(Path path) throws IOException, MetaException {
- ContentSummary contents = getFs(path).getContentSummary(path);
- if (contents != null && contents.getFileCount() == 0 &&
contents.getDirectoryCount() == 1) {
+ public boolean isEmptyDir(Path path) throws IOException, MetaException {
+ int listCount = getFs(path).listStatus(path).length;
+ if (listCount == 0) {
return true;
}
return false;
diff --git
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 3397f93..29b4358 100644
---
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -4703,7 +4703,7 @@ public class HiveMetaStore extends ThriftHiveMetastore {
private void deleteParentRecursive(Path parent, int depth, boolean
mustPurge, boolean needRecycle)
throws IOException, MetaException {
if (depth > 0 && parent != null && wh.isWritable(parent)) {
- if (wh.isDir(parent) && wh.isEmpty(parent)) {
+ if (wh.isDir(parent) && wh.isEmptyDir(parent)) {
wh.deleteDir(parent, true, mustPurge, needRecycle);
}
deleteParentRecursive(parent.getParent(), depth - 1, mustPurge,
needRecycle);