You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hj...@apache.org on 2014/12/05 09:21:21 UTC

[17/29] tajo git commit: TAJO-1224: When there is no projected columns, json scan can be hang.

TAJO-1224: When there is no projected columns, json scan can be hang.

Closes #281


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

Branch: refs/heads/hbase_storage
Commit: 9f8be1a695298e2e9fe0d881ddfcb310b5a7460b
Parents: 20d1f01
Author: Hyunsik Choi <hy...@apache.org>
Authored: Thu Dec 4 10:55:19 2014 +0900
Committer: Hyunsik Choi <hy...@apache.org>
Committed: Thu Dec 4 11:28:44 2014 +0900

----------------------------------------------------------------------
 CHANGES                                          |  3 +++
 .../tajo/engine/query/TestCaseByCases.java       |  8 ++++++++
 .../TestCaseByCases/testTAJO1224Case1.sql        |  1 +
 .../TestCaseByCases/testTAJO1224Case1.result     |  3 +++
 .../tajo/storage/text/DelimitedTextFile.java     | 19 ++++++++++++-------
 5 files changed, 27 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/9f8be1a6/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index ea8e1ca..60aa3e0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -83,6 +83,9 @@ Release 0.9.1 - unreleased
 
   BUG FIXES
 
+    TAJO-1224: When there is no projected column, json scan can be hang. 
+    (hyunsik) 
+
     TAJO-1220: Implement createStatement() and setEscapeProcessing() in 
     JdbcConnection. (YeonSu Han via hyunsik)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/9f8be1a6/tajo-core/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
index 846c290..bcf00f8 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
@@ -172,4 +172,12 @@ public class TestCaseByCases extends QueryTestCaseBase {
     assertResultSet(res);
     cleanupQuery(res);
   }
+
+  @Test
+  public final void testTAJO1224Case1() throws Exception {
+    executeString("CREATE TABLE TAJO1224 USING JSON AS SELECT * FROM LINEITEM").close();
+    ResultSet res = executeQuery();
+    assertResultSet(res);
+    cleanupQuery(res);
+  }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/9f8be1a6/tajo-core/src/test/resources/queries/TestCaseByCases/testTAJO1224Case1.sql
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/queries/TestCaseByCases/testTAJO1224Case1.sql b/tajo-core/src/test/resources/queries/TestCaseByCases/testTAJO1224Case1.sql
new file mode 100644
index 0000000..d05a563
--- /dev/null
+++ b/tajo-core/src/test/resources/queries/TestCaseByCases/testTAJO1224Case1.sql
@@ -0,0 +1 @@
+select count(*) from tajo1224;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/9f8be1a6/tajo-core/src/test/resources/results/TestCaseByCases/testTAJO1224Case1.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestCaseByCases/testTAJO1224Case1.result b/tajo-core/src/test/resources/results/TestCaseByCases/testTAJO1224Case1.result
new file mode 100644
index 0000000..19336a7
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestCaseByCases/testTAJO1224Case1.result
@@ -0,0 +1,3 @@
+?count
+-------------------------------
+5
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/9f8be1a6/tajo-storage/src/main/java/org/apache/tajo/storage/text/DelimitedTextFile.java
----------------------------------------------------------------------
diff --git a/tajo-storage/src/main/java/org/apache/tajo/storage/text/DelimitedTextFile.java b/tajo-storage/src/main/java/org/apache/tajo/storage/text/DelimitedTextFile.java
index c54131b..ab8a0b5 100644
--- a/tajo-storage/src/main/java/org/apache/tajo/storage/text/DelimitedTextFile.java
+++ b/tajo-storage/src/main/java/org/apache/tajo/storage/text/DelimitedTextFile.java
@@ -358,29 +358,34 @@ public class DelimitedTextFile {
 
     @Override
     public Tuple next() throws IOException {
+      VTuple tuple;
 
       if (!reader.isReadable()) {
         return null;
       }
 
-      if (targets.length == 0) {
-        return EmptyTuple.get();
-      }
-
-      VTuple tuple = new VTuple(schema.size());
-
       try {
 
         // this loop will continue until one tuple is build or EOS (end of stream).
         do {
 
           ByteBuf buf = reader.readLine();
+
+          // if no more line, then return EOT (end of tuple)
           if (buf == null) {
             return null;
           }
 
-          try {
+          // If there is no required column, we just read each line
+          // and then return an empty tuple without parsing line.
+          if (targets.length == 0) {
+            recordCount++;
+            return EmptyTuple.get();
+          }
 
+          tuple = new VTuple(schema.size());
+
+          try {
             deserializer.deserialize(buf, tuple);
             // if a line is read normaly, it exists this loop.
             break;