phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryann...@apache.org
Subject phoenix git commit: Code refine for PhoenixSchema
Date Thu, 30 Apr 2015 20:45:22 GMT
Repository: phoenix
Updated Branches:
  refs/heads/calcite 8e3f68a2d -> 1ee1f2011


Code refine for PhoenixSchema


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

Branch: refs/heads/calcite
Commit: 1ee1f2011eda8a3b22c855e7730ed74b1bd628a9
Parents: 8e3f68a
Author: maryannxue <wei.xue@intel.com>
Authored: Thu Apr 30 16:45:13 2015 -0400
Committer: maryannxue <wei.xue@intel.com>
Committed: Thu Apr 30 16:45:13 2015 -0400

----------------------------------------------------------------------
 .../apache/phoenix/calcite/PhoenixSchema.java   | 22 +++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1ee1f201/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSchema.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSchema.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSchema.java
index 816c156..589f61d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSchema.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSchema.java
@@ -40,34 +40,36 @@ public class PhoenixSchema implements Schema {
         this.schemaName = name;
         this.pc = pc;
         this.client = new MetaDataClient(pc);
-        this.subSchemaNames = Sets.newHashSet();
-        this.tableNames = Sets.newHashSet();
-        if (schemaName == null) {
-            loadSubSchemaNames();
-        }
-        loadTableNames();
+        this.subSchemaNames = name == null ? 
+                  ImmutableSet.<String> copyOf(loadSubSchemaNames()) 
+                : Collections.<String> emptySet();
+        this.tableNames = ImmutableSet.<String> copyOf(loadTableNames());
     }
     
-    private void loadSubSchemaNames() {
+    private Set<String> loadSubSchemaNames() {
         try {
             DatabaseMetaData md = pc.getMetaData();
             ResultSet rs = md.getSchemas();
+            Set<String> subSchemaNames = Sets.newHashSet();
             while (rs.next()) {
                 String schemaName = rs.getString(PhoenixDatabaseMetaData.TABLE_SCHEM);
-                this.subSchemaNames.add(schemaName == null ? "" : schemaName);
+                subSchemaNames.add(schemaName == null ? "" : schemaName);
             }
+            return subSchemaNames;
         } catch (SQLException e) {
             throw new RuntimeException(e);
         }
     }
     
-    private void loadTableNames() {
+    private Set<String> loadTableNames() {
         try {
             DatabaseMetaData md = pc.getMetaData();
             ResultSet rs = md.getTables(null, schemaName == null ? "" : schemaName, null,
null);
+            Set<String> tableNames = Sets.newHashSet();
             while (rs.next()) {
-                this.tableNames.add(rs.getString(PhoenixDatabaseMetaData.TABLE_NAME));
+                tableNames.add(rs.getString(PhoenixDatabaseMetaData.TABLE_NAME));
             }
+            return tableNames;
         } catch (SQLException e) {
             throw new RuntimeException(e);
         }


Mime
View raw message