ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [2/2] incubator-ignite git commit: # IGNITE-32: Use indexes instead of columns names.
Date Mon, 02 Feb 2015 13:29:32 GMT
# IGNITE-32: Use indexes instead of columns names.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/605088c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/605088c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/605088c6

Branch: refs/heads/ignite-32
Commit: 605088c60865dd9bed40525ce547a0dbb183c0b7
Parents: 54ed9b1
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Mon Feb 2 20:29:24 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Mon Feb 2 20:29:24 2015 +0700

----------------------------------------------------------------------
 .../parser/dialect/JdbcMetadataDialect.java     | 36 ++++++++++++++++----
 .../parser/dialect/OracleMetadataDialect.java   | 10 +++---
 2 files changed, 34 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/605088c6/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
index 4e34f35..c9cf0cf 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
@@ -32,6 +32,28 @@ public class JdbcMetadataDialect extends DatabaseMetadataDialect {
     /** */
     private static final String[] TABLES_AND_VIEWS = {"TABLE", "VIEW"};
 
+    /** Schema name index. */
+    private static final int SCHEMA_NAME_IDX = 1;
+
+    /** Schema catalog index. */
+    private static final int SCHEMA_CATALOG_IDX = 2;
+
+    /** Table name index. */
+    private static final int TABLE_NAME_IDX = 3;
+
+    /** Primary key column name index. */
+    private static final int PK_COLUMN_NAME_IDX = 4;
+
+    /** Column name index. */
+    private static final int COLUMN_NAME_IDX = 4;
+
+    /** Column data type index. */
+    private static final int COLUMN_DATA_TYPE_IDX = 5;
+
+    /** Column nullable index. */
+    private static final int COLUMN_NULLABLE_IDX = 11;
+
+
     /** {@inheritDoc} */
     @Override public Collection<DbTable> tables(Connection conn, boolean tblsOnly)
throws SQLException {
         DatabaseMetaData dbMeta = conn.getMetaData();
@@ -42,37 +64,37 @@ public class JdbcMetadataDialect extends DatabaseMetadataDialect {
 
         try (ResultSet schemasRs = dbMeta.getSchemas()) {
             while (schemasRs.next()) {
-                String schema = schemasRs.getString("TABLE_SCHEM");
+                String schema = schemasRs.getString(SCHEMA_NAME_IDX);
 
                 // Skip system schemas.
                 if (sys.contains(schema))
                     continue;
 
-                String catalog = schemasRs.getString("TABLE_CATALOG");
+                String catalog = schemasRs.getString(SCHEMA_CATALOG_IDX);
 
                 try (ResultSet tblsRs = dbMeta.getTables(catalog, schema, "%",
                     tblsOnly ? TABLES_ONLY : TABLES_AND_VIEWS)) {
                     while (tblsRs.next()) {
-                        String tblName = tblsRs.getString("TABLE_NAME");
+                        String tblName = tblsRs.getString(TABLE_NAME_IDX);
 
                         Set<String> pkCols = new HashSet<>();
 
                         try (ResultSet pkRs = dbMeta.getPrimaryKeys(catalog, schema, tblName))
{
                             while (pkRs.next())
-                                pkCols.add(pkRs.getString("COLUMN_NAME"));
+                                pkCols.add(pkRs.getString(PK_COLUMN_NAME_IDX));
                         }
 
                         List<DbColumn> cols = new ArrayList<>();
 
                         try (ResultSet colsRs = dbMeta.getColumns(catalog, schema, tblName,
null)) {
                             while (colsRs.next()) {
-                                String colName = colsRs.getString("COLUMN_NAME");
+                                String colName = colsRs.getString(COLUMN_NAME_IDX);
 
                                 cols.add(new DbColumn(
                                     colName,
-                                    colsRs.getInt("DATA_TYPE"),
+                                    colsRs.getInt(COLUMN_DATA_TYPE_IDX),
                                     pkCols.contains(colName),
-                                    colsRs.getInt("NULLABLE") == DatabaseMetaData.columnNullable));
+                                    colsRs.getInt(COLUMN_NULLABLE_IDX) == DatabaseMetaData.columnNullable));
                             }
                         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/605088c6/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
index 81a9442..363c7b2 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
@@ -145,8 +145,8 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
                 String prevTbl = "";
 
                 while (colsRs.next()) {
-                    String schema = colsRs.getString("OWNER");
-                    String tbl = colsRs.getString("TABLE_NAME");
+                    String schema = colsRs.getString(SQL_COLS_OWNER);
+                    String tbl = colsRs.getString(SQL_COLS_TAB_NAME);
 
                     if (prevSchema.isEmpty()) {
                         prevSchema = schema;
@@ -162,10 +162,10 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
 
                         cols = new ArrayList<>();
                     }
-                    cols.add(new DbColumn(colsRs.getString("COLUMN_NAME"),
-                        decodeType(colsRs.getString("DATA_TYPE")),
+                    cols.add(new DbColumn(colsRs.getString(SQL_COLS_COL_NAME),
+                        decodeType(colsRs.getString(SQL_COLS_DATA_TYPE)),
                         false,
-                        decodeNullable(colsRs.getString("NULLABLE"))
+                        decodeNullable(colsRs.getString(SQL_COLS_NULLABLE))
                     ));
                 }
 


Mime
View raw message