You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by pv...@apache.org on 2017/08/07 08:41:12 UTC

hive git commit: HIVE-16294: Support snapshot for truncate table (Barna Zsombor Klara, via Peter Vary)

Repository: hive
Updated Branches:
  refs/heads/master 99137f8eb -> acb03dba4


HIVE-16294: Support snapshot for truncate table (Barna Zsombor Klara, via Peter Vary)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/acb03dba
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/acb03dba
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/acb03dba

Branch: refs/heads/master
Commit: acb03dba4ae858ba83910a74af08dc9df7920c54
Parents: 99137f8
Author: Peter Vary <pv...@cloudera.com>
Authored: Mon Aug 7 10:40:25 2017 +0200
Committer: Peter Vary <pv...@cloudera.com>
Committed: Mon Aug 7 10:40:25 2017 +0200

----------------------------------------------------------------------
 .../apache/hadoop/hive/common/FileUtils.java    | 21 ++++++++++++++++++++
 .../hadoop/hive/metastore/HiveMetaStore.java    |  2 +-
 2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/acb03dba/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
----------------------------------------------------------------------
diff --git a/common/src/java/org/apache/hadoop/hive/common/FileUtils.java b/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
index e8a3a7a..2880eb2 100644
--- a/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
+++ b/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
@@ -81,6 +81,27 @@ public final class FileUtils {
     }
   };
 
+  public static final PathFilter SNAPSHOT_DIR_PATH_FILTER = new PathFilter() {
+    @Override
+    public boolean accept(Path p) {
+      return ".snapshot".equalsIgnoreCase(p.getName());
+    }
+  };
+
+  /**
+   * Check if the path contains a subdirectory named '.snapshot'
+   * @param p path to check
+   * @param fs filesystem of the path
+   * @return true if p contains a subdirectory named '.snapshot'
+   * @throws IOException
+   */
+  public static boolean pathHasSnapshotSubDir(Path p, FileSystem fs) throws IOException {
+    // Hadoop is missing a public API to check for snapshotable directories. Check with the directory name
+    // until a more appropriate API is provided by HDFS-12257.
+    final FileStatus[] statuses = fs.listStatus(p, FileUtils.SNAPSHOT_DIR_PATH_FILTER);
+    return statuses != null && statuses.length != 0;
+  }
+
   /**
    * Variant of Path.makeQualified that qualifies the input path against the default file system
    * indicated by the configuration

http://git-wip-us.apache.org/repos/asf/hive/blob/acb03dba/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 6a6fd43..e2a7d7d 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -2158,7 +2158,7 @@ public class HiveMetaStore extends ThriftHiveMetastore {
           FileSystem fs = location.getFileSystem(getHiveConf());
           HadoopShims.HdfsEncryptionShim shim
                   = ShimLoader.getHadoopShims().createHdfsEncryptionShim(fs, getHiveConf());
-          if (!shim.isPathEncrypted(location)) {
+          if (!shim.isPathEncrypted(location) && !FileUtils.pathHasSnapshotSubDir(location, fs)) {
             HdfsUtils.HadoopFileStatus status = new HdfsUtils.HadoopFileStatus(getHiveConf(), fs, location);
             FileStatus targetStatus = fs.getFileStatus(location);
             String targetGroup = targetStatus == null ? null : targetStatus.getGroup();