You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2018/06/01 20:36:39 UTC

hive git commit: HIVE-19432 : GetTablesOperation is too slow if the hive has too many databases and tables (Rajkumar Singh via Ashutosh Chauhan)

Repository: hive
Updated Branches:
  refs/heads/master 36d66f0cf -> 4463c2bd5


HIVE-19432 : GetTablesOperation is too slow if the hive has too many databases and tables (Rajkumar Singh via Ashutosh Chauhan)

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


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

Branch: refs/heads/master
Commit: 4463c2bd52d64d8639a477f46d05239d3d0bb5be
Parents: 36d66f0
Author: Rajkumar Singh <ra...@gmail.com>
Authored: Sat May 5 15:58:00 2018 -0700
Committer: Ashutosh Chauhan <ha...@apache.org>
Committed: Fri Jun 1 13:35:42 2018 -0700

----------------------------------------------------------------------
 .../cli/operation/GetTablesOperation.java       | 43 +++++++++++---------
 1 file changed, 24 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/4463c2bd/service/src/java/org/apache/hive/service/cli/operation/GetTablesOperation.java
----------------------------------------------------------------------
diff --git a/service/src/java/org/apache/hive/service/cli/operation/GetTablesOperation.java b/service/src/java/org/apache/hive/service/cli/operation/GetTablesOperation.java
index 1b5b09a..aaee2ce 100644
--- a/service/src/java/org/apache/hive/service/cli/operation/GetTablesOperation.java
+++ b/service/src/java/org/apache/hive/service/cli/operation/GetTablesOperation.java
@@ -39,6 +39,9 @@ import org.apache.hive.service.cli.session.HiveSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+
+
+
 /**
  * GetTablesOperation.
  *
@@ -110,27 +113,29 @@ public class GetTablesOperation extends MetadataOperation {
       }
 
       String tablePattern = convertIdentifierPattern(tableName, true);
+      for (String dbName : metastoreClient.getDatabases(schemaPattern)) {
+        String dbNamePattern = convertIdentifierPattern(dbName, true);
+        for (TableMeta tableMeta :
+                metastoreClient.getTableMeta(dbNamePattern, tablePattern, tableTypeList)) {
+          String tableType = tableTypeMapping.mapToClientType(tableMeta.getTableType());
+          rowSet.addRow(new Object[]{
+                  DEFAULT_HIVE_CATALOG,
+                  tableMeta.getDbName(),
+                  tableMeta.getTableName(),
+                  tableType,
+                  tableMeta.getComments(),
+                  null, null, null, null, null
+          });
 
-      for (TableMeta tableMeta :
-          metastoreClient.getTableMeta(schemaPattern, tablePattern, tableTypeList)) {
-        String tableType = tableTypeMapping.mapToClientType(tableMeta.getTableType());
-        rowSet.addRow(new Object[] {
-              DEFAULT_HIVE_CATALOG,
-              tableMeta.getDbName(),
-              tableMeta.getTableName(),
-              tableType,
-              tableMeta.getComments(),
-              null, null, null, null, null
-              });
-
-        if (LOG.isDebugEnabled()) {
-          String debugMessage = getDebugMessage("table", RESULT_SET_SCHEMA);
-          LOG.debug(debugMessage, DEFAULT_HIVE_CATALOG, tableMeta.getDbName(),
-              tableMeta.getTableName(), tableType, tableMeta.getComments());
+          if (LOG.isDebugEnabled()) {
+            String debugMessage = getDebugMessage("table", RESULT_SET_SCHEMA);
+            LOG.debug(debugMessage, DEFAULT_HIVE_CATALOG, tableMeta.getDbName(),
+                    tableMeta.getTableName(), tableType, tableMeta.getComments());
+          }
+        }
+        if (LOG.isDebugEnabled() && rowSet.numRows() == 0) {
+          LOG.debug("No table metadata has been returned.");
         }
-      }
-      if (LOG.isDebugEnabled() && rowSet.numRows() == 0) {
-        LOG.debug("No table metadata has been returned.");
       }
       setState(OperationState.FINISHED);
       LOG.info("Fetching table metadata has been successfully finished");