You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ai...@apache.org on 2018/07/30 18:06:25 UTC

hive git commit: HIVE-19809: Remove Deprecated Code From Utilities Class (BELUGA BEHR, reviewed by Aihua Xu)

Repository: hive
Updated Branches:
  refs/heads/master 1c8449cce -> 109ec31dc


HIVE-19809: Remove Deprecated Code From Utilities Class (BELUGA BEHR, reviewed by Aihua Xu)


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

Branch: refs/heads/master
Commit: 109ec31dc7de5678106e702c9bdd641c12cb1653
Parents: 1c8449c
Author: Aihua Xu <ai...@apache.org>
Authored: Fri Jul 13 15:47:34 2018 -0700
Committer: Aihua Xu <ai...@apache.org>
Committed: Mon Jul 30 11:05:26 2018 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hive/ql/QTestUtil.java    |  4 ++-
 .../apache/hadoop/hive/ql/exec/Utilities.java   | 26 --------------------
 2 files changed, 3 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/109ec31d/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java
----------------------------------------------------------------------
diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java b/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java
index 4ed062e..5adbb63 100644
--- a/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java
+++ b/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java
@@ -36,6 +36,8 @@ import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -1834,7 +1836,7 @@ public class QTestUtil {
       if (zooKeeperCluster == null) {
         //create temp dir
         String tmpBaseDir =  System.getProperty(TEST_TMP_DIR_PROPERTY);
-        File tmpDir = Utilities.createTempDir(tmpBaseDir);
+        File tmpDir = Files.createTempDirectory(Paths.get(tmpBaseDir), "tmp_").toFile();
 
         zooKeeperCluster = new MiniZooKeeperCluster();
         zkPort = zooKeeperCluster.startup(tmpDir);

http://git-wip-us.apache.org/repos/asf/hive/blob/109ec31d/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
index 80478ca..b677d46 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
@@ -3758,32 +3758,6 @@ public final class Utilities {
   }
 
   /**
-   * Create a temp dir in specified baseDir
-   * This can go away once hive moves to support only JDK 7
-   *  and can use Files.createTempDirectory
-   *  Guava Files.createTempDir() does not take a base dir
-   * @param baseDir - directory under which new temp dir will be created
-   * @return File object for new temp dir
-   */
-  public static File createTempDir(String baseDir){
-    //try creating the temp dir MAX_ATTEMPTS times
-    final int MAX_ATTEMPS = 30;
-    for(int i = 0; i < MAX_ATTEMPS; i++){
-      //pick a random file name
-      String tempDirName = "tmp_" + ((int)(100000 * Math.random()));
-
-      //return if dir could successfully be created with that file name
-      File tempDir = new File(baseDir, tempDirName);
-      if(tempDir.mkdir()){
-        return tempDir;
-      }
-    }
-    throw new IllegalStateException("Failed to create a temp dir under "
-    + baseDir + " Giving up after " + MAX_ATTEMPS + " attempts");
-
-  }
-
-  /**
    * Skip header lines in the table file when reading the record.
    *
    * @param currRecReader