Browse Source

HADOOP-4120. Hive interactive shell records the time taken by a
query. (Raghotham Murthy via dhruba)



git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@697285 13f79535-47bb-0310-9956-ffa450edef68

Dhruba Borthakur 16 years ago
parent
commit
0818807b91

+ 3 - 0
CHANGES.txt

@@ -703,6 +703,9 @@ Trunk (unreleased changes)
     HADOOP-3592. Fix a couple of possible file leaks in FileUtil
     (Bill de hOra via rangadi)
 
+    HADOOP-4120. Hive interactive shell records the time taken by a 
+    query.  (Raghotham Murthy via dhruba)
+
 Release 0.18.1 - 2008-09-17
 
   IMPROVEMENTS

+ 11 - 0
src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java

@@ -28,6 +28,9 @@ import org.apache.hadoop.hive.ql.exec.Utilities;
 import org.apache.hadoop.hive.ql.exec.Utilities.StreamPrinter;
 import org.apache.hadoop.hive.ql.session.SessionState;
 import org.apache.hadoop.hive.ql.Driver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hive.ql.session.SessionState.LogHelper;
 
 public class CliDriver {
 
@@ -193,8 +196,16 @@ public class CliDriver {
     String historyFile = System.getProperty("user.home") + File.separator  + HISTORYFILE;
     reader.setHistory(new History(new File(historyFile)));
     int ret = 0;
+    Log LOG = LogFactory.getLog("CliDriver");
+    LogHelper console = new LogHelper(LOG);
     while ((line = reader.readLine(prompt+"> ")) != null) {
+      long start = System.currentTimeMillis();
       ret = processLine(line);
+      long end = System.currentTimeMillis();
+      if (end > start) {
+        double timeTaken = (double)(end-start)/1000.0;
+        console.printInfo("Time taken: " + timeTaken + " seconds", null);
+      }
     }
 
     System.exit(ret);