hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1600951 - /hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
Date Fri, 06 Jun 2014 16:17:59 GMT
Author: hashutosh
Date: Fri Jun  6 16:17:58 2014
New Revision: 1600951

URL: http://svn.apache.org/r1600951
Log:
HIVE-7136 : Allow Hive to read hive scripts from any of the supported file systems in hadoop
eco-system (Sumit Kumar via Ashutosh Chauhan)

Modified:
    hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java

Modified: hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
URL: http://svn.apache.org/viewvc/hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java?rev=1600951&r1=1600950&r2=1600951&view=diff
==============================================================================
--- hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java (original)
+++ hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java Fri Jun  6 16:17:58
2014
@@ -23,8 +23,8 @@ import static org.apache.hadoop.util.Str
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
 import java.sql.SQLException;
@@ -46,6 +46,8 @@ import org.apache.commons.lang.StringUti
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.common.HiveInterruptUtils;
 import org.apache.hadoop.hive.common.LogUtils;
 import org.apache.hadoop.hive.common.LogUtils.LogInitializationException;
@@ -466,15 +468,19 @@ public class CliDriver {
   }
 
   public int processFile(String fileName) throws IOException {
-    FileReader fileReader = null;
+    Path path = new Path(fileName);
+    FileSystem fs;
+    if (!path.toUri().isAbsolute()) {
+      fs = FileSystem.getLocal(conf);
+      path = fs.makeQualified(path);
+    } else {
+      fs = FileSystem.get(path.toUri(), conf);
+    }
     BufferedReader bufferReader = null;
     int rc = 0;
     try {
-      fileReader = new FileReader(fileName);
-      bufferReader = new BufferedReader(fileReader);
+      bufferReader = new BufferedReader(new InputStreamReader(fs.open(path)));
       rc = processReader(bufferReader);
-      bufferReader.close();
-      bufferReader = null;
     } finally {
       IOUtils.closeStream(bufferReader);
     }



Mime
View raw message