tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject tajo git commit: TAJO-1154: TajoCli doesn't pause while running the non-forwarded query. (Hyoungjun Kim via hyunsik)
Date Sun, 09 Nov 2014 07:59:34 GMT
Repository: tajo
Updated Branches:
  refs/heads/master 5c82b7db4 -> d65224293


TAJO-1154: TajoCli doesn't pause while running the non-forwarded query. (Hyoungjun Kim via
hyunsik)

Closes #227


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

Branch: refs/heads/master
Commit: d65224293671501639772db2141a316752078d76
Parents: 5c82b7d
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Sat Nov 8 23:50:05 2014 -0800
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Sat Nov 8 23:50:05 2014 -0800

----------------------------------------------------------------------
 CHANGES                                         |  3 ++
 .../cli/tsql/DefaultTajoCliOutputFormatter.java |  6 ++--
 .../cli/tsql/commands/DescTableCommand.java     |  4 +--
 .../org/apache/tajo/client/QueryClient.java     |  2 --
 .../java/org/apache/tajo/TajoConstants.java     |  1 +
 .../org/apache/tajo/master/GlobalEngine.java    |  7 ++--
 .../org/apache/tajo/cli/tsql/TestTajoCli.java   | 36 ++++++++++++++++++++
 .../TestTajoCli/testNonForwardQueryPause.result |  5 +++
 8 files changed, 55 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/d6522429/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 913d26b..1d51416 100644
--- a/CHANGES
+++ b/CHANGES
@@ -32,6 +32,9 @@ Release 0.9.1 - unreleased
 
   BUG FIXES
 
+    TAJO-1154: TajoCli doesn't pause while running the non-forwarded 
+    query. (Hyoungjun Kim via hyunsik)
+
     TAJO-1150: Some weird methods in QueryClientImpl should be fixed. 
     (Jongyoung Park via hyunsik)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/d6522429/tajo-client/src/main/java/org/apache/tajo/cli/tsql/DefaultTajoCliOutputFormatter.java
----------------------------------------------------------------------
diff --git a/tajo-client/src/main/java/org/apache/tajo/cli/tsql/DefaultTajoCliOutputFormatter.java
b/tajo-client/src/main/java/org/apache/tajo/cli/tsql/DefaultTajoCliOutputFormatter.java
index 9dd2b1c..8d8c023 100644
--- a/tajo-client/src/main/java/org/apache/tajo/cli/tsql/DefaultTajoCliOutputFormatter.java
+++ b/tajo-client/src/main/java/org/apache/tajo/cli/tsql/DefaultTajoCliOutputFormatter.java
@@ -21,9 +21,9 @@ package org.apache.tajo.cli.tsql;
 import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.tajo.QueryId;
 import org.apache.tajo.SessionVars;
+import org.apache.tajo.TajoConstants;
 import org.apache.tajo.catalog.TableDesc;
 import org.apache.tajo.catalog.statistics.TableStats;
-import org.apache.tajo.client.QueryClient;
 import org.apache.tajo.client.QueryStatus;
 import org.apache.tajo.util.FileUtil;
 
@@ -56,10 +56,10 @@ public class DefaultTajoCliOutputFormatter implements TajoCliOutputFormatter
{
     TableStats stat = tableDesc.getStats();
     String volume = stat == null ? (endOfTuple ? "0 B" : "unknown bytes") :
         FileUtil.humanReadableByteCount(stat.getNumBytes(), false);
-    long resultRows = stat == null ? QueryClient.UNKNOWN_ROW_NUMBER : stat.getNumRows();
+    long resultRows = stat == null ? TajoConstants.UNKNOWN_ROW_NUMBER : stat.getNumRows();
 
     String displayRowNum;
-    if (resultRows == QueryClient.UNKNOWN_ROW_NUMBER) {
+    if (resultRows == TajoConstants.UNKNOWN_ROW_NUMBER) {
 
       if (endOfTuple) {
         displayRowNum = totalPrintedRows + " rows";

http://git-wip-us.apache.org/repos/asf/tajo/blob/d6522429/tajo-client/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
----------------------------------------------------------------------
diff --git a/tajo-client/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
b/tajo-client/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
index 2d4408b..5eebc2b 100644
--- a/tajo-client/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
+++ b/tajo-client/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
@@ -20,11 +20,11 @@ package org.apache.tajo.cli.tsql.commands;
 
 import org.apache.commons.lang.CharUtils;
 import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.tajo.TajoConstants;
 import org.apache.tajo.catalog.Column;
 import org.apache.tajo.catalog.TableDesc;
 import org.apache.tajo.catalog.partition.PartitionMethodDesc;
 import org.apache.tajo.cli.tsql.TajoCli;
-import org.apache.tajo.client.QueryClient;
 import org.apache.tajo.util.FileUtil;
 import org.apache.tajo.util.TUtil;
 
@@ -83,7 +83,7 @@ public class DescTableCommand extends TajoShellCommand {
     if (desc.getStats() != null) {
 
       long row = desc.getStats().getNumRows();
-      String rowText = row == QueryClient.UNKNOWN_ROW_NUMBER ? "unknown" : row + "";
+      String rowText = row == TajoConstants.UNKNOWN_ROW_NUMBER ? "unknown" : row + "";
       sb.append("number of rows: ").append(rowText).append("\n");
       sb.append("volume: ").append(
           FileUtil.humanReadableByteCount(desc.getStats().getNumBytes(),

http://git-wip-us.apache.org/repos/asf/tajo/blob/d6522429/tajo-client/src/main/java/org/apache/tajo/client/QueryClient.java
----------------------------------------------------------------------
diff --git a/tajo-client/src/main/java/org/apache/tajo/client/QueryClient.java b/tajo-client/src/main/java/org/apache/tajo/client/QueryClient.java
index dbbafb6..59ef52b 100644
--- a/tajo-client/src/main/java/org/apache/tajo/client/QueryClient.java
+++ b/tajo-client/src/main/java/org/apache/tajo/client/QueryClient.java
@@ -34,8 +34,6 @@ import static org.apache.tajo.TajoIdProtos.SessionIdProto;
 
 public interface QueryClient extends Closeable {
 
-  int UNKNOWN_ROW_NUMBER = -1;
-
   public void setSessionId(SessionIdProto sessionId);
 
   public boolean isConnected();

http://git-wip-us.apache.org/repos/asf/tajo/blob/d6522429/tajo-common/src/main/java/org/apache/tajo/TajoConstants.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/TajoConstants.java b/tajo-common/src/main/java/org/apache/tajo/TajoConstants.java
index be61783..1cc28af 100644
--- a/tajo-common/src/main/java/org/apache/tajo/TajoConstants.java
+++ b/tajo-common/src/main/java/org/apache/tajo/TajoConstants.java
@@ -37,6 +37,7 @@ public class TajoConstants {
   public static final String SYSTEM_HA_DIR_NAME = "ha";
   public static final String SYSTEM_HA_ACTIVE_DIR_NAME = "active";
   public static final String SYSTEM_HA_BACKUP_DIR_NAME = "backup";
+  public static final int UNKNOWN_ROW_NUMBER = -1;
 
 
   private TajoConstants() {}

http://git-wip-us.apache.org/repos/asf/tajo/blob/d6522429/tajo-core/src/main/java/org/apache/tajo/master/GlobalEngine.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/master/GlobalEngine.java b/tajo-core/src/main/java/org/apache/tajo/master/GlobalEngine.java
index f7c7b11..9831c00 100644
--- a/tajo-core/src/main/java/org/apache/tajo/master/GlobalEngine.java
+++ b/tajo-core/src/main/java/org/apache/tajo/master/GlobalEngine.java
@@ -41,7 +41,6 @@ import org.apache.tajo.catalog.exception.*;
 import org.apache.tajo.catalog.partition.PartitionMethodDesc;
 import org.apache.tajo.catalog.proto.CatalogProtos;
 import org.apache.tajo.catalog.statistics.TableStats;
-import org.apache.tajo.client.QueryClient;
 import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.conf.TajoConf;
 import org.apache.tajo.datum.DatumFactory;
@@ -255,6 +254,10 @@ public class GlobalEngine extends AbstractService {
         LimitNode limitNode = plan.getRootBlock().getNode(NodeType.LIMIT);
         maxRow = (int) limitNode.getFetchFirstNum();
       }
+      if (desc.getStats().getNumRows() == 0) {
+        desc.getStats().setNumRows(TajoConstants.UNKNOWN_ROW_NUMBER);
+      }
+
       QueryId queryId = QueryIdFactory.newQueryId(context.getResourceManager().getSeedQueryId());
 
       NonForwardQueryResultScanner queryResultScanner =
@@ -761,7 +764,7 @@ public class GlobalEngine extends AbstractService {
     stats.setNumBytes(totalSize);
 
     if (isExternal) { // if it is an external table, there is no way to know the exact row
number without processing.
-      stats.setNumRows(QueryClient.UNKNOWN_ROW_NUMBER);
+      stats.setNumRows(TajoConstants.UNKNOWN_ROW_NUMBER);
     }
 
     TableDesc desc = new TableDesc(CatalogUtil.buildFQName(databaseName, simpleTableName),

http://git-wip-us.apache.org/repos/asf/tajo/blob/d6522429/tajo-core/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java b/tajo-core/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
index c5ff00b..797544f 100644
--- a/tajo-core/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
+++ b/tajo-core/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
@@ -27,6 +27,7 @@ import org.apache.tajo.ConfigKey;
 import org.apache.tajo.SessionVars;
 import org.apache.tajo.TajoTestingCluster;
 import org.apache.tajo.TpchTestBase;
+import org.apache.tajo.catalog.TableDesc;
 import org.apache.tajo.cli.tsql.DefaultTajoCliOutputFormatter;
 import org.apache.tajo.cli.tsql.TajoCli;
 import org.apache.tajo.client.QueryStatus;
@@ -343,6 +344,41 @@ public class TestTajoCli {
     assertOutputResult(new String(out.toByteArray()));
   }
 
+  @Test
+  public void testNonForwardQueryPause() throws Exception {
+    final String sql = "select * from default.lineitem";
+    try {
+      TableDesc tableDesc = cluster.getMaster().getCatalog().getTableDesc("default", "lineitem");
+      assertNotNull(tableDesc);
+      assertEquals(0L, tableDesc.getStats().getNumRows().longValue());
+      setVar(tajoCli, SessionVars.CLI_PAGE_ROWS, "2");
+      setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName());
+      Thread t = new Thread() {
+        public void run() {
+          try {
+            tajoCli.executeScript(sql);
+          } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+          }
+        }
+      };
+      t.start();
+      String consoleResult;
+      while (true) {
+        Thread.sleep(3 * 1000);
+        consoleResult = new String(out.toByteArray());
+        if (consoleResult.indexOf("row") >= 0) {
+          t.interrupt();
+          break;
+        }
+      }
+      assertOutputResult(consoleResult);
+    } finally {
+      setVar(tajoCli, SessionVars.CLI_PAGE_ROWS, "100");
+    }
+  }
+
   public static class TajoCliOutputTestFormatter extends DefaultTajoCliOutputFormatter {
     @Override
     protected String getResponseTimeReadable(float responseTime) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/d6522429/tajo-core/src/test/resources/results/TestTajoCli/testNonForwardQueryPause.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestTajoCli/testNonForwardQueryPause.result
b/tajo-core/src/test/resources/results/TestTajoCli/testNonForwardQueryPause.result
new file mode 100644
index 0000000..e9485d0
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestTajoCli/testNonForwardQueryPause.result
@@ -0,0 +1,5 @@
+l_orderkey,  l_partkey,  l_suppkey,  l_linenumber,  l_quantity,  l_extendedprice,  l_discount,
 l_tax,  l_returnflag,  l_linestatus,  l_shipdate,  l_commitdate,  l_receiptdate,  l_shipinstruct,
 l_shipmode,  l_comment
+-------------------------------
+1,  1,  7706,  1,  17.0,  21168.23,  0.04,  0.02,  N,  O,  1996-03-13,  1996-02-12,  1996-03-22,
 DELIVER IN PERSON,  TRUCK,  egular courts above the
+1,  1,  7311,  2,  36.0,  45983.16,  0.09,  0.06,  N,  O,  1996-04-12,  1996-02-28,  1996-04-20,
 TAKE BACK RETURN,  MAIL,  ly final dependencies: slyly bold 
+(2 rows, continue... 'q' is quit)
\ No newline at end of file


Mime
View raw message