tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject tajo git commit: TAJO-1939: Implement PgSQLTablespace::getTableVolume() method.
Date Mon, 15 Feb 2016 07:34:25 GMT
Repository: tajo
Updated Branches:
  refs/heads/branch-0.11.2 a0fdb3622 -> cfdf4c39d


TAJO-1939: Implement PgSQLTablespace::getTableVolume() method.


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

Branch: refs/heads/branch-0.11.2
Commit: cfdf4c39de47282553f38897d5e7c1a028adeebb
Parents: a0fdb36
Author: Jihoon Son <jihoonson@apache.org>
Authored: Mon Feb 15 16:34:16 2016 +0900
Committer: Jihoon Son <jihoonson@apache.org>
Committed: Mon Feb 15 16:34:16 2016 +0900

----------------------------------------------------------------------
 CHANGES                                         |  2 ++
 .../tajo/querymaster/DefaultTaskScheduler.java  |  7 ++---
 .../tajo/storage/pgsql/PgSQLTablespace.java     | 29 ++++++++++++++++++--
 .../storage/pgsql/TestPgSQLJdbcTableSpace.java  | 12 ++++++++
 .../tajo/storage/pgsql/TestPgSQLQueryTests.java |  5 ++--
 5 files changed, 46 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/cfdf4c39/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index ba2589d..938abda 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,8 @@ Release 0.11.2 - unreleased
 
   TASKS
 
+    TAJO-1939: Implement PgSQLTablespace::getTableVolume() method. (jihoon)
+
     TAJO-2017: Replace manual array copy with Collection.
     (Dongkyu Hwangbo via jinho)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/cfdf4c39/tajo-core/src/main/java/org/apache/tajo/querymaster/DefaultTaskScheduler.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/querymaster/DefaultTaskScheduler.java
b/tajo-core/src/main/java/org/apache/tajo/querymaster/DefaultTaskScheduler.java
index 8142e39..8b79972 100644
--- a/tajo-core/src/main/java/org/apache/tajo/querymaster/DefaultTaskScheduler.java
+++ b/tajo-core/src/main/java/org/apache/tajo/querymaster/DefaultTaskScheduler.java
@@ -48,7 +48,6 @@ import org.apache.tajo.rpc.NettyClientBase;
 import org.apache.tajo.rpc.RpcClientManager;
 import org.apache.tajo.service.ServiceTracker;
 import org.apache.tajo.storage.DataLocation;
-import org.apache.tajo.storage.fragment.FileFragment;
 import org.apache.tajo.storage.fragment.Fragment;
 import org.apache.tajo.util.NetUtils;
 import org.apache.tajo.util.RpcParameterFactory;
@@ -217,13 +216,13 @@ public class DefaultTaskScheduler extends AbstractTaskScheduler {
           }
           stage.getEventHandler().handle(new TaskEvent(task.getId(), TaskEventType.T_SCHEDULE));
         } else {
-          fragmentsForNonLeafTask = new FileFragment[2];
+          fragmentsForNonLeafTask = new Fragment[2];
           fragmentsForNonLeafTask[0] = castEvent.getLeftFragment();
           if (castEvent.hasRightFragments()) {
-            FileFragment[] rightFragments = castEvent.getRightFragments().toArray(new FileFragment[]{});
+            Fragment[] rightFragments = castEvent.getRightFragments().toArray(new Fragment[]{});
             fragmentsForNonLeafTask[1] = rightFragments[0];
             if (rightFragments.length > 1) {
-              broadcastFragmentsForNonLeafTask = new FileFragment[rightFragments.length -
1];
+              broadcastFragmentsForNonLeafTask = new Fragment[rightFragments.length - 1];
               System.arraycopy(rightFragments, 1, broadcastFragmentsForNonLeafTask, 0, broadcastFragmentsForNonLeafTask.length);
             } else {
               broadcastFragmentsForNonLeafTask = null;

http://git-wip-us.apache.org/repos/asf/tajo/blob/cfdf4c39/tajo-storage/tajo-storage-pgsql/src/main/java/org/apache/tajo/storage/pgsql/PgSQLTablespace.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-pgsql/src/main/java/org/apache/tajo/storage/pgsql/PgSQLTablespace.java
b/tajo-storage/tajo-storage-pgsql/src/main/java/org/apache/tajo/storage/pgsql/PgSQLTablespace.java
index 1969d13..91ed8c7 100644
--- a/tajo-storage/tajo-storage-pgsql/src/main/java/org/apache/tajo/storage/pgsql/PgSQLTablespace.java
+++ b/tajo-storage/tajo-storage-pgsql/src/main/java/org/apache/tajo/storage/pgsql/PgSQLTablespace.java
@@ -18,11 +18,14 @@
 
 package org.apache.tajo.storage.pgsql;
 
+import com.google.common.base.Optional;
 import net.minidev.json.JSONObject;
-import org.apache.tajo.catalog.MetadataProvider;
-import org.apache.tajo.catalog.Schema;
-import org.apache.tajo.catalog.TableMeta;
+import org.apache.tajo.catalog.*;
 import org.apache.tajo.exception.TajoInternalError;
+import org.apache.tajo.exception.TajoRuntimeException;
+import org.apache.tajo.exception.UndefinedTableException;
+import org.apache.tajo.exception.UnsupportedException;
+import org.apache.tajo.plan.expr.EvalNode;
 import org.apache.tajo.storage.NullScanner;
 import org.apache.tajo.storage.Scanner;
 import org.apache.tajo.storage.fragment.Fragment;
@@ -32,6 +35,9 @@ import org.apache.tajo.storage.jdbc.JdbcTablespace;
 import javax.annotation.Nullable;
 import java.io.IOException;
 import java.net.URI;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
 
 /**
  * Postgresql Database Tablespace
@@ -68,4 +74,21 @@ public class PgSQLTablespace extends JdbcTablespace {
     scanner.setTarget(target.toArray());
     return scanner;
   }
+
+  @Override
+//  public long getTableVolume(TableDesc table, Optional<EvalNode> filter) throws UnsupportedException
{
+  public long getTableVolume(TableDesc table, Optional<EvalNode> filter) {
+    String sql = "SELECT pg_table_size('" + CatalogUtil.extractSimpleName(table.getName())
+ "')";
+
+    try (Statement stmt = conn.createStatement();
+         ResultSet rs = stmt.executeQuery(sql)) {
+      if (rs.next()) {
+        return rs.getLong(1);
+      } else {
+        throw new TajoRuntimeException(new UndefinedTableException(table.getName()));
+      }
+    } catch (SQLException e) {
+      throw new TajoInternalError(e);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/cfdf4c39/tajo-storage/tajo-storage-pgsql/src/test/java/org/apache/tajo/storage/pgsql/TestPgSQLJdbcTableSpace.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-pgsql/src/test/java/org/apache/tajo/storage/pgsql/TestPgSQLJdbcTableSpace.java
b/tajo-storage/tajo-storage-pgsql/src/test/java/org/apache/tajo/storage/pgsql/TestPgSQLJdbcTableSpace.java
index 05b26e8..92e4ebf 100644
--- a/tajo-storage/tajo-storage-pgsql/src/test/java/org/apache/tajo/storage/pgsql/TestPgSQLJdbcTableSpace.java
+++ b/tajo-storage/tajo-storage-pgsql/src/test/java/org/apache/tajo/storage/pgsql/TestPgSQLJdbcTableSpace.java
@@ -25,6 +25,9 @@ import org.apache.tajo.catalog.TableDesc;
 import org.apache.tajo.conf.TajoConf;
 import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.exception.TajoRuntimeException;
+import org.apache.tajo.exception.UndefinedTablespaceException;
+import org.apache.tajo.exception.UnsupportedException;
+import org.apache.tajo.plan.expr.EvalNode;
 import org.apache.tajo.storage.Tablespace;
 import org.apache.tajo.storage.TablespaceManager;
 import org.apache.tajo.storage.fragment.Fragment;
@@ -134,4 +137,13 @@ public class TestPgSQLJdbcTableSpace {
 
     TablespaceManager.addTableSpaceForTest(ts.get());
   }
+
+  @Test
+  public void testGetTableVolume() throws UndefinedTablespaceException, UnsupportedException
{
+    Tablespace space = TablespaceManager.getByName("pgsql_cluster");
+    MetadataProvider provider = space.getMetadataProvider();
+    TableDesc table = provider.getTableDesc(null, "lineitem");
+    long volume = space.getTableVolume(table, Optional.<EvalNode>absent());
+    assertEquals(8192, volume);
+  }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/cfdf4c39/tajo-storage/tajo-storage-pgsql/src/test/java/org/apache/tajo/storage/pgsql/TestPgSQLQueryTests.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-pgsql/src/test/java/org/apache/tajo/storage/pgsql/TestPgSQLQueryTests.java
b/tajo-storage/tajo-storage-pgsql/src/test/java/org/apache/tajo/storage/pgsql/TestPgSQLQueryTests.java
index 52b7531..ac387e9 100644
--- a/tajo-storage/tajo-storage-pgsql/src/test/java/org/apache/tajo/storage/pgsql/TestPgSQLQueryTests.java
+++ b/tajo-storage/tajo-storage-pgsql/src/test/java/org/apache/tajo/storage/pgsql/TestPgSQLQueryTests.java
@@ -113,8 +113,9 @@ public class TestPgSQLQueryTests extends QueryTestCaseBase {
     runSimpleTests();
   }
 
-  @SimpleTest
-  @Test
+//  @SimpleTest
+//  @Test
+  // TODO: enable this test after allowing consecutive cross joins (TAJO-2075)
   @Option(sort = true)
   public void testTPCH_Q5() throws Exception {
     runSimpleTests();


Mime
View raw message