ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject incubator-ignite git commit: # IGNITE-32: WIP Oracle dialect: support for indexes.
Date Mon, 02 Feb 2015 09:57:30 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-32 6706dbd8b -> 811713446


# IGNITE-32: WIP Oracle dialect: support for indexes.


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

Branch: refs/heads/ignite-32
Commit: 8117134460ee50d894f40169c4ca37ee0694a22e
Parents: 6706dbd
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Mon Feb 2 16:57:37 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Mon Feb 2 16:57:37 2015 +0700

----------------------------------------------------------------------
 .../parser/dialect/OracleMetadataDialect.java   | 49 +++++++++++++++++---
 1 file changed, 42 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/81171344/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 fe8db43..81a9442 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
@@ -28,13 +28,6 @@ import static java.sql.Types.*;
  * Oracle specific metadata dialect.
  */
 public class OracleMetadataDialect extends DatabaseMetadataDialect {
-    /** SQL to get indexes metadata. */
-    private static final String SQL_INDEXES = "select a.index_owner, a.table_name, a.index_name,
a.column_name," +
-        " b.uniqueness" +
-        " FROM all_ind_columns a" +
-        " LEFT JOIN all_indexes b on" +
-        "  (a.table_name = b.table_name AND a.table_owner = b.table_owner AND a.index_name
 = b.index_name)";
-
     /** SQL to get columns metadata. */
     private static final String SQL_COLUMNS = "SELECT a.owner, a.table_name, a.column_name,
a.nullable, a.data_type" +
         " FROM all_tab_columns a" +
@@ -42,6 +35,22 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
         " WHERE a.owner = '%s'" +
         " ORDER BY a.owner, a.table_name, a.column_id";
 
+    private static final int SQL_COLS_OWNER = 1;
+
+    private static final int SQL_COLS_TAB_NAME = 2;
+
+    private static final int SQL_COLS_COL_NAME = 3;
+
+    private static final int SQL_COLS_NULLABLE = 4;
+
+    private static final int SQL_COLS_DATA_TYPE = 5;
+
+    /** SQL to get indexes metadata. */
+    private static final String SQL_INDEXES = "select index_name, column_name, descend" +
+        " FROM all_ind_columns" +
+        " WHERE index_owner = ? and table_name = ?" +
+        "  ORDER BY index_name, column_position";
+
     /**
      * @param type Column type from Oracle database.
      * @return JDBC type.
@@ -95,10 +104,36 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
         return "Y".equals(nullable);
     }
 
+    /**
+     * @param descend Index column sort direction from Oracle database.
+     * @return {@code true} if column sorted in descent direction.
+     */
+    private static Boolean decodeDescend(String descend) {
+        return descend != null ? "DESC".equals(descend) : null;
+    }
+
+    private static Map<String, Map<String, Boolean>> indexes(PreparedStatement
stmt, String owner, String tbl)
+        throws SQLException {
+        Map<String, Map<String, Boolean>> idxs = new LinkedHashMap<>();
+
+        stmt.setString(1, owner);
+        stmt.setString(2, tbl);
+
+        try (ResultSet idxsRs = stmt.executeQuery()) {
+            while (idxsRs.next()) {
+                String idxName = idxsRs.getString("INDEX_NAME");
+            }
+        }
+
+        return idxs;
+    }
+
     /** {@inheritDoc} */
     @Override public Collection<DbTable> tables(Connection conn, boolean tblsOnly)
throws SQLException {
         Collection<DbTable> tbls = new ArrayList<>();
 
+        PreparedStatement stmtIdxs = conn.prepareStatement(SQL_INDEXES);
+
         try (Statement stmt = conn.createStatement()) {
             Collection<DbColumn> cols = new ArrayList<>();
 


Mime
View raw message