hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject hive git commit: HIVE-13385 : [Cleanup] Streamline Beeline instantiation (Reuben Kuhnert via Ashutosh Chauhan)
Date Sun, 10 Apr 2016 00:31:58 GMT
Repository: hive
Updated Branches:
  refs/heads/master 3d7554447 -> caafd88f9


HIVE-13385 : [Cleanup] Streamline Beeline instantiation (Reuben Kuhnert via Ashutosh Chauhan)

Signed-off-by: Ashutosh Chauhan <hashutosh@apache.org>


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

Branch: refs/heads/master
Commit: caafd88f9b50241ece9fcf5ed173409c3aef0d25
Parents: 3d75544
Author: Reuben Kuhnert <sircodesalot@gmail.com>
Authored: Wed Mar 30 06:40:00 2016 -0800
Committer: Ashutosh Chauhan <hashutosh@apache.org>
Committed: Sat Apr 9 17:29:41 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/hive/beeline/BeeLine.java   | 18 ++------------
 .../hive/beeline/BeeLineCommandCompleter.java   | 26 +++++++++++---------
 2 files changed, 16 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/caafd88f/beeline/src/java/org/apache/hive/beeline/BeeLine.java
----------------------------------------------------------------------
diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLine.java b/beeline/src/java/org/apache/hive/beeline/BeeLine.java
index a4a9558..98d4e09 100644
--- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java
+++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java
@@ -118,7 +118,6 @@ public class BeeLine implements Closeable {
   private boolean exit = false;
   private final DatabaseConnections connections = new DatabaseConnections();
   public static final String COMMAND_PREFIX = "!";
-  private final Completer beeLineCommandCompleter;
   private Collection<Driver> drivers = null;
   private final BeeLineOpts opts = new BeeLineOpts(this, System.getProperties());
   private String lastProgress = null;
@@ -130,7 +129,7 @@ public class BeeLine implements Closeable {
   private PrintStream errorStream = new PrintStream(System.err, true);
   private ConsoleReader consoleReader;
   private List<String> batch = null;
-  private final Reflector reflector;
+  private final Reflector reflector = new Reflector(this);
   private String dbName = null;
   private String currentDatabase = null;
 
@@ -266,6 +265,7 @@ public class BeeLine implements Closeable {
           null)
   };
 
+  private final Completer beeLineCommandCompleter = new BeeLineCommandCompleter(Arrays.asList(commandHandlers));
 
   static final SortedSet<String> KNOWN_DRIVERS = new TreeSet<String>(Arrays.asList(
       new String[] {
@@ -503,21 +503,7 @@ public class BeeLine implements Closeable {
   }
 
   public BeeLine(boolean isBeeLine) {
-    beeLineCommandCompleter = new BeeLineCommandCompleter(BeeLineCommandCompleter.getCompleters
-        (this));
-    reflector = new Reflector(this);
     this.isBeeLine = isBeeLine;
-    // attempt to dynamically load signal handler
-    /* TODO disable signal handler
-    try {
-      Class<?> handlerClass =
-          Class.forName("org.apache.hive.beeline.SunSignalHandler");
-      signalHandler = (BeeLineSignalHandler)
-          handlerClass.newInstance();
-    } catch (Throwable t) {
-      // ignore and leave cancel functionality disabled
-    }
-    */
   }
 
   DatabaseConnection getDatabaseConnection() {

http://git-wip-us.apache.org/repos/asf/hive/blob/caafd88f/beeline/src/java/org/apache/hive/beeline/BeeLineCommandCompleter.java
----------------------------------------------------------------------
diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLineCommandCompleter.java b/beeline/src/java/org/apache/hive/beeline/BeeLineCommandCompleter.java
index 6a872bc..87e7518 100644
--- a/beeline/src/java/org/apache/hive/beeline/BeeLineCommandCompleter.java
+++ b/beeline/src/java/org/apache/hive/beeline/BeeLineCommandCompleter.java
@@ -27,24 +27,26 @@ import jline.console.completer.NullCompleter;
 import jline.console.completer.StringsCompleter;
 
 class BeeLineCommandCompleter extends AggregateCompleter {
-
-  public BeeLineCommandCompleter(List<Completer> completers) {
-    super(completers);
+  public BeeLineCommandCompleter(Iterable<CommandHandler> handlers) {
+    super(getCompleters(handlers));
   }
 
-  public static List<Completer> getCompleters(BeeLine beeLine){
+  public static List<Completer> getCompleters(Iterable<CommandHandler> handlers){
     List<Completer> completers = new LinkedList<Completer>();
 
-    for (int i = 0; i < beeLine.commandHandlers.length; i++) {
-      String[] cmds = beeLine.commandHandlers[i].getNames();
-      for (int j = 0; cmds != null && j < cmds.length; j++) {
-        List<Completer> compl = new LinkedList<Completer>();
-        compl.add(new StringsCompleter(BeeLine.COMMAND_PREFIX + cmds[j]));
-        compl.addAll(Arrays.asList(beeLine.commandHandlers[i].getParameterCompleters()));
-        compl.add(new NullCompleter()); // last param no complete
-        completers.add(new AggregateCompleter(compl.toArray(new Completer[0])));
+    for (CommandHandler handler : handlers) {
+      String[] commandNames = handler.getNames();
+      if (commandNames != null) {
+        for (String commandName : commandNames) {
+          List<Completer> compl = new LinkedList<Completer>();
+          compl.add(new StringsCompleter(BeeLine.COMMAND_PREFIX + commandName));
+          compl.addAll(Arrays.asList(handler.getParameterCompleters()));
+          compl.add(new NullCompleter()); // last param no complete
+          completers.add(new AggregateCompleter(compl.toArray(new Completer[compl.size()])));
+        }
       }
     }
+
     return completers;
   }
 }
\ No newline at end of file


Mime
View raw message