tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject [1/6] tajo git commit: TAJO-1259: Change tsql history behavior. (Jaewoong Jung via hyunsik)
Date Thu, 25 Dec 2014 10:28:27 GMT
Repository: tajo
Updated Branches:
  refs/heads/index_support 3b5c28711 -> 7a38895d4


TAJO-1259: Change tsql history behavior. (Jaewoong Jung via hyunsik)

Closes #316


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

Branch: refs/heads/index_support
Commit: c39ed5dc9e5b6ec80a87baf08d79fbb640fb886f
Parents: 3c833e2
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Wed Dec 24 14:40:45 2014 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Wed Dec 24 14:40:45 2014 +0900

----------------------------------------------------------------------
 CHANGES                                               |  2 ++
 .../main/java/org/apache/tajo/cli/tsql/TajoCli.java   | 14 +++++++++-----
 .../org/apache/tajo/cli/tsql/TajoFileHistory.java     |  8 +++-----
 3 files changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/c39ed5dc/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 29b0c0b..1bc8b9e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -24,6 +24,8 @@ Release 0.9.1 - unreleased
 
   IMPROVEMENT
 
+    TAJO-1259: Change tsql history behavior. (Jaewoong Jung via hyunsik)
+
     TAJO-1261: Separate query and ddl execution codes from GlobalEngine. 
     (hyunsik)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/c39ed5dc/tajo-client/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java
----------------------------------------------------------------------
diff --git a/tajo-client/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java b/tajo-client/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java
index 6c5006e..fe9a005 100644
--- a/tajo-client/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java
+++ b/tajo-client/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java
@@ -338,6 +338,8 @@ public class TajoCli {
       String historyPath = HOME_DIR + File.separator + HISTORY_FILE;
       if ((new File(HOME_DIR)).exists()) {
         history = new TajoFileHistory(new File(historyPath));
+        history.setAutoTrim(false);
+        history.setIgnoreDuplicates(false);
         reader.setHistory(history);
       } else {
         System.err.println(ERROR_PREFIX + "home directory : '" + HOME_DIR +"' does not exist.");
@@ -391,6 +393,7 @@ public class TajoCli {
     String line;
     String currentPrompt = context.getCurrentDatabase();
     int exitCode;
+    ParsingState latestState = SimpleParser.START_STATE;
 
     sout.write("Try \\? for help.\n");
 
@@ -407,14 +410,15 @@ public class TajoCli {
         } else {
           List<ParsedResult> parsedResults = parser.parseLines(line);
 
-          if (parsedResults.size() > 0) {
-            for (ParsedResult parsed : parsedResults) {
-              history.addStatement(parsed.getHistoryStatement() + (parsed.getType() == STATEMENT
? ";" : ""));
-            }
+          if (latestState != ParsingState.TOK_START && parsedResults.size() >
0) {
+            // Add multi-line statements to history in addition to individual lines.
+            ParsedResult parsed = parsedResults.get(0);
+            history.add(parsed.getHistoryStatement() + (parsed.getType() == STATEMENT ? ";"
: ""));
           }
 
           exitCode = executeParsedResults(parsedResults);
-          currentPrompt = updatePrompt(parser.getState());
+          latestState = parser.getState();
+          currentPrompt = updatePrompt(latestState);
 
           // if at least one failed
           if (exitCode != 0) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/c39ed5dc/tajo-client/src/main/java/org/apache/tajo/cli/tsql/TajoFileHistory.java
----------------------------------------------------------------------
diff --git a/tajo-client/src/main/java/org/apache/tajo/cli/tsql/TajoFileHistory.java b/tajo-client/src/main/java/org/apache/tajo/cli/tsql/TajoFileHistory.java
index ec0275c..9b1a5b8 100644
--- a/tajo-client/src/main/java/org/apache/tajo/cli/tsql/TajoFileHistory.java
+++ b/tajo-client/src/main/java/org/apache/tajo/cli/tsql/TajoFileHistory.java
@@ -29,11 +29,9 @@ public class TajoFileHistory extends FileHistory {
     super(file);
   }
 
+  @Override
   public void add(CharSequence item) {
-    // skip add
-  }
-
-  public void addStatement(String item) {
-    internalAdd(item);
+    // TODO: Filter out the quit command. Users wouldn't want it in the history.
+    super.add(item);
   }
 }


Mime
View raw message